mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(fork): scope task list invalidation to current workspace (#4350)
* fix(fork): scope task list invalidation to current workspace * fix(sidebar): remove mutation objects from useCallback deps Mutation objects are not referentially stable in TanStack Query v5 — only .mutate() and .mutateAsync() are stable. Removed deleteTaskMutation, deleteTasksMutation, markTaskReadMutation, and markTaskUnreadMutation from their respective useCallback dependency arrays to avoid unnecessary recreations on every mutation state update.
This commit is contained in:
@@ -72,7 +72,7 @@ export const MessageActions = memo(function MessageActions({
|
||||
const resetTimeoutRef = useRef<number | null>(null)
|
||||
const requestIdTimeoutRef = useRef<number | null>(null)
|
||||
const submitFeedback = useSubmitCopilotFeedback()
|
||||
const forkTask = useForkTask()
|
||||
const forkTask = useForkTask(params.workspaceId)
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
||||
@@ -896,7 +896,7 @@ export const Sidebar = memo(function Sidebar() {
|
||||
deleteTasksMutation.mutate(taskIdsToDelete, { onSuccess: onDeleteSuccess })
|
||||
}
|
||||
setIsTaskDeleteModalOpen(false)
|
||||
}, [pathname, workspaceId, deleteTaskMutation, deleteTasksMutation, navigateToPage])
|
||||
}, [pathname, workspaceId, navigateToPage])
|
||||
|
||||
const [visibleTaskCount, setVisibleTaskCount] = useState(5)
|
||||
const taskFlyoutRename = useFlyoutInlineRename({
|
||||
@@ -935,13 +935,13 @@ export const Sidebar = memo(function Sidebar() {
|
||||
const { taskIds: ids } = contextMenuSelectionRef.current
|
||||
if (ids.length !== 1) return
|
||||
markTaskReadMutation.mutate(ids[0])
|
||||
}, [markTaskReadMutation])
|
||||
}, [])
|
||||
|
||||
const handleMarkTaskAsUnread = useCallback(() => {
|
||||
const { taskIds: ids } = contextMenuSelectionRef.current
|
||||
if (ids.length !== 1) return
|
||||
markTaskUnreadMutation.mutate(ids[0])
|
||||
}, [markTaskUnreadMutation])
|
||||
}, [])
|
||||
|
||||
const handleStartTaskRename = useCallback(() => {
|
||||
const { taskIds: ids } = contextMenuSelectionRef.current
|
||||
|
||||
@@ -605,12 +605,12 @@ async function forkChat(params: {
|
||||
return { id: data.id }
|
||||
}
|
||||
|
||||
export function useForkTask() {
|
||||
export function useForkTask(workspaceId?: string) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: forkChat,
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries({ queryKey: taskKeys.lists() })
|
||||
queryClient.invalidateQueries({ queryKey: taskKeys.list(workspaceId) })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user