File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -586,6 +586,7 @@ export const Sidebar = memo(function Sidebar() {
586586 } , [ activeNavItemHref ] )
587587
588588 const createTaskMutation = useCreateTask ( workspaceId )
589+ const isCreatingTaskRef = useRef ( false )
589590 const deleteTaskMutation = useDeleteTask ( workspaceId )
590591 const deleteTasksMutation = useDeleteTasks ( workspaceId )
591592 const markTaskReadMutation = useMarkTaskRead ( workspaceId )
@@ -1161,13 +1162,16 @@ export const Sidebar = memo(function Sidebar() {
11611162 }
11621163
11631164 const handleNewTask = useCallback ( async ( ) => {
1164- if ( ! workspaceId ) return
1165+ if ( ! workspaceId || isCreatingTaskRef . current ) return
1166+ isCreatingTaskRef . current = true
11651167 try {
11661168 const { id } = await createTaskMutation . mutateAsync ( )
11671169 useMothershipDraftsStore . getState ( ) . clearDraft ( `${ workspaceId } :new` )
11681170 navigateToPage ( `/workspace/${ workspaceId } /task/${ id } ` )
11691171 } catch {
11701172 navigateToPage ( `/workspace/${ workspaceId } /home` )
1173+ } finally {
1174+ isCreatingTaskRef . current = false
11711175 }
11721176 } , [ workspaceId , navigateToPage ] )
11731177
You can’t perform that action at this time.
0 commit comments