From d42dd3061a035bc2a512628a8bac82f292f002da Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Wed, 22 Jul 2026 16:44:32 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(frontend)=20refresh=20the=20storage?= =?UTF-8?q?=20gauge=20on=20move=20and=20duplicate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Duplicating an item consumes storage and moving an item to or from the root can change who owns its usage. Invalidate the entitlements cache on success so the gauge reflects the new usage without a reload. --- .../apps/drive/src/features/explorer/api/useMoveItem.tsx | 3 +++ .../apps/drive/src/features/explorer/hooks/useMutations.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/frontend/apps/drive/src/features/explorer/api/useMoveItem.tsx b/src/frontend/apps/drive/src/features/explorer/api/useMoveItem.tsx index 9cc15186..3f1c7a7d 100644 --- a/src/frontend/apps/drive/src/features/explorer/api/useMoveItem.tsx +++ b/src/frontend/apps/drive/src/features/explorer/api/useMoveItem.tsx @@ -7,6 +7,7 @@ import { ToasterItem, } from "@/features/ui/components/toaster/Toaster"; import { useRemoveItemsFromPaginatedList } from "../hooks/useOptimisticPagination"; +import { useRefreshEntitlementsQueryCache } from "../hooks/useRefreshItems"; import { getMyFilesQueryKey, getRecentItemsQueryKey, @@ -25,6 +26,7 @@ export const useMoveItems = () => { const driver = getDriver(); const removeItems = useRemoveItemsFromPaginatedList(); + const refreshEntitlements = useRefreshEntitlementsQueryCache(); return useMutation({ mutationFn: async (payload: MoveItemPayload) => { @@ -48,6 +50,7 @@ export const useMoveItems = () => { queryClient.invalidateQueries({ queryKey: ["items", payload.parentId], }); + refreshEntitlements(); }, onError: (err, variables) => { // If the mutation fails, you could invalidate to ensure fresh data diff --git a/src/frontend/apps/drive/src/features/explorer/hooks/useMutations.ts b/src/frontend/apps/drive/src/features/explorer/hooks/useMutations.ts index 389ee15d..94a0e2bc 100644 --- a/src/frontend/apps/drive/src/features/explorer/hooks/useMutations.ts +++ b/src/frontend/apps/drive/src/features/explorer/hooks/useMutations.ts @@ -12,6 +12,7 @@ import { useDeleteMutationCallbacks, useRefreshItemCache, useRefreshFavoriteCache, + useRefreshEntitlementsQueryCache, } from "./useRefreshItems"; import { DefaultRoute } from "@/utils/defaultRoutes"; @@ -222,6 +223,7 @@ export const useMutationDuplicateItem = () => { const { item } = useGlobalExplorer(); const refresh = useRefreshQueryCacheAfterMutation(); + const refreshEntitlements = useRefreshEntitlementsQueryCache(); return useMutation({ mutationFn: (itemId: string) => { @@ -230,6 +232,7 @@ export const useMutationDuplicateItem = () => { onSuccess: () => { const parentId = item?.originalId ?? item?.id; refresh(parentId); + refreshEntitlements(); }, meta: { // The caller already toasts a localized message on failure.