@@ -86,12 +86,10 @@ export function useWebhookManagement({
8686 return
8787 }
8888
89- // If already checked and webhookId exists, skip fetching
9089 if ( alreadyChecked && currentWebhookId ) {
9190 return
9291 }
9392
94- // If already checked but webhookId is null, allow re-checking (handles timing issues)
9593 if ( alreadyChecked && ! currentWebhookId ) {
9694 useSubBlockStore . setState ( ( state ) => {
9795 const newSet = new Set ( state . checkedWebhooks )
@@ -114,10 +112,8 @@ export function useWebhookManagement({
114112
115113 try {
116114 const response = await fetch ( `/api/webhooks?workflowId=${ workflowId } &blockId=${ blockId } ` )
117- const stillMounted = isMounted // Capture mount state at response time
115+ const stillMounted = isMounted
118116
119- // Process response even if component unmounted, since we're using Zustand (global store)
120- // The webhookId should be set in the store regardless of component lifecycle
121117 if ( response . ok ) {
122118 const data = await response . json ( )
123119
@@ -140,10 +136,8 @@ export function useWebhookManagement({
140136 }
141137
142138 if ( webhook . providerConfig ) {
143- // Determine triggerId from multiple sources
144139 let effectiveTriggerId : string | undefined = triggerId
145140 if ( ! effectiveTriggerId ) {
146- // Try to get from stored value
147141 const storedTriggerId = useSubBlockStore . getState ( ) . getValue ( blockId , 'triggerId' )
148142 effectiveTriggerId =
149143 ( typeof storedTriggerId === 'string' ? storedTriggerId : undefined ) || undefined
@@ -155,7 +149,6 @@ export function useWebhookManagement({
155149 : undefined
156150 }
157151 if ( ! effectiveTriggerId ) {
158- // Try to determine from block config
159152 const workflowState = useWorkflowStore . getState ( )
160153 const block = workflowState . blocks ?. [ blockId ]
161154 if ( block ) {
@@ -205,7 +198,6 @@ export function useWebhookManagement({
205198 useSubBlockStore . getState ( ) . setValue ( blockId , 'webhookId' , null )
206199 }
207200
208- // Mark as checked even if component unmounted, since Zustand state persists
209201 useSubBlockStore . setState ( ( state ) => ( {
210202 checkedWebhooks : new Set ( [ ...state . checkedWebhooks , blockId ] ) ,
211203 } ) )
@@ -233,7 +225,6 @@ export function useWebhookManagement({
233225 return ( ) => {
234226 isMounted = false
235227 }
236- // Note: Intentionally not including webhookId in dependencies to avoid re-running when it changes
237228 // eslint-disable-next-line react-hooks/exhaustive-deps
238229 } , [ isPreview , triggerId , workflowId , blockId ] )
239230
0 commit comments