From 94458c2f1ea103bc14fc73c08a586131e59a6dfd Mon Sep 17 00:00:00 2001 From: Kenneth Date: Tue, 23 Dec 2025 18:59:19 +0000 Subject: [PATCH] fix: create dir mutation wrong query invalidation --- apps/drive-web/src/vfs/api.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/drive-web/src/vfs/api.ts b/apps/drive-web/src/vfs/api.ts index 42cc590..f17a321 100644 --- a/apps/drive-web/src/vfs/api.ts +++ b/apps/drive-web/src/vfs/api.ts @@ -10,6 +10,7 @@ import { atom } from "jotai" import { atomFamily } from "jotai/utils" import { currentAccountAtom } from "@/account/account" import { fetchApi } from "@/lib/api" +import type { AtomValue } from "@/lib/jotai-utils" import { DirectoryContent, DirectoryInfo, @@ -179,11 +180,12 @@ export const createDirectoryMutationAtom = atom((get) => { }, ).then(([_, result]) => result) }, - onSuccess: (data, _variables, _context, { client }) => { - client.setQueryData( - get(directoryInfoQueryAtom(data.id)).queryKey, - data, - ) + onSuccess: (_data, { parentId }, _context, { client }) => { + if (account) { + client.invalidateQueries({ + queryKey: directoryContentQueryKey(account.id, parentId), + }) + } }, }) })