@@ -292,7 +292,7 @@ export function useExecutionSnapshot(executionId: string | undefined) {
292292 } )
293293}
294294
295- export function useCancelExecution ( ) {
295+ export function useCancelExecution ( workspaceId : string ) {
296296 const queryClient = useQueryClient ( )
297297 return useMutation ( {
298298 mutationFn : async ( {
@@ -316,7 +316,6 @@ export function useCancelExecution() {
316316 } )
317317
318318 let affectedLogId : string | null = null
319- let affectedWorkspaceId : string | undefined
320319 queryClient . setQueriesData < InfiniteData < LogsPage > > ( { queryKey : logKeys . lists ( ) } , ( old ) => {
321320 if ( ! old ) return old
322321 return {
@@ -326,7 +325,6 @@ export function useCancelExecution() {
326325 logs : page . logs . map ( ( log ) => {
327326 if ( log . executionId !== executionId ) return log
328327 affectedLogId = log . id
329- affectedWorkspaceId = log . workflow ?. workspaceId ?? undefined
330328 return { ...log , status : 'cancelling' }
331329 } ) ,
332330 } ) ) ,
@@ -336,28 +334,25 @@ export function useCancelExecution() {
336334 let previousDetail : WorkflowLogDetail | undefined
337335 if ( affectedLogId ) {
338336 previousDetail = queryClient . getQueryData < WorkflowLogDetail > (
339- logKeys . detail ( affectedWorkspaceId , affectedLogId )
337+ logKeys . detail ( workspaceId , affectedLogId )
340338 )
341339 if ( previousDetail ) {
342- queryClient . setQueryData < WorkflowLogDetail > (
343- logKeys . detail ( affectedWorkspaceId , affectedLogId ) ,
344- {
345- ...previousDetail ,
346- status : 'cancelling' ,
347- }
348- )
340+ queryClient . setQueryData < WorkflowLogDetail > ( logKeys . detail ( workspaceId , affectedLogId ) , {
341+ ...previousDetail ,
342+ status : 'cancelling' ,
343+ } )
349344 }
350345 }
351346
352- return { previousQueries, affectedLogId, affectedWorkspaceId , previousDetail }
347+ return { previousQueries, affectedLogId, previousDetail }
353348 } ,
354349 onError : ( _err , _variables , context ) => {
355350 for ( const [ queryKey , data ] of context ?. previousQueries ?? [ ] ) {
356351 queryClient . setQueryData ( queryKey , data )
357352 }
358353 if ( context ?. affectedLogId && context . previousDetail !== undefined ) {
359354 queryClient . setQueryData (
360- logKeys . detail ( context . affectedWorkspaceId , context . affectedLogId ) ,
355+ logKeys . detail ( workspaceId , context . affectedLogId ) ,
361356 context . previousDetail
362357 )
363358 }
0 commit comments