File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -614,7 +614,13 @@ export function useCreateTask(workspaceId?: string) {
614614 isUnread : false ,
615615 isPinned : false ,
616616 }
617- queryClient . setQueryData < TaskMetadata [ ] > ( taskKeys . list ( workspaceId ) , [ newTask , ...existing ] )
617+ const pinnedCount = existing . findIndex ( ( task ) => ! task . isPinned )
618+ const insertAt = pinnedCount === - 1 ? existing . length : pinnedCount
619+ queryClient . setQueryData < TaskMetadata [ ] > ( taskKeys . list ( workspaceId ) , [
620+ ...existing . slice ( 0 , insertAt ) ,
621+ newTask ,
622+ ...existing . slice ( insertAt ) ,
623+ ] )
618624 } ,
619625 onSettled : ( ) => {
620626 if ( ! workspaceId ) return
@@ -653,9 +659,12 @@ export function useForkTask(workspaceId?: string) {
653659 isUnread : false ,
654660 isPinned : false ,
655661 }
662+ const pinnedCount = existing . findIndex ( ( task ) => ! task . isPinned )
663+ const insertAt = pinnedCount === - 1 ? existing . length : pinnedCount
656664 queryClient . setQueryData < TaskMetadata [ ] > ( taskKeys . list ( workspaceId ) , [
665+ ...existing . slice ( 0 , insertAt ) ,
657666 optimisticTask ,
658- ...existing ,
667+ ...existing . slice ( insertAt ) ,
659668 ] )
660669 }
661670 } ,
You can’t perform that action at this time.
0 commit comments