diff --git a/src/library-authoring/data/apiHooks.ts b/src/library-authoring/data/apiHooks.ts index 159fc8e6d7..e1ab38f1f5 100644 --- a/src/library-authoring/data/apiHooks.ts +++ b/src/library-authoring/data/apiHooks.ts @@ -113,6 +113,8 @@ export const xblockQueryKeys = { export function invalidateComponentData(queryClient: QueryClient, contentLibraryId: string, usageKey: string) { queryClient.invalidateQueries({ queryKey: xblockQueryKeys.xblockFields(usageKey) }); queryClient.invalidateQueries({ queryKey: xblockQueryKeys.componentMetadata(usageKey) }); + // The description and display name etc. may have changed, so refresh everything in the library too: + queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibrary(contentLibraryId) }); queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, contentLibraryId) }); } @@ -150,8 +152,6 @@ export const useDeleteLibraryBlock = () => { mutationFn: deleteLibraryBlock, onSettled: (_data, _error, variables) => { const libraryId = getLibraryId(variables.usageKey); - queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibrary(libraryId) }); - queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, libraryId) }); invalidateComponentData(queryClient, libraryId, variables.usageKey); }, }); @@ -367,11 +367,7 @@ export const useUpdateXBlockOLX = (usageKey: string) => { mutationFn: (newOLX: string) => setXBlockOLX(usageKey, newOLX), onSuccess: (olxFromServer) => { queryClient.setQueryData(xblockQueryKeys.xblockOLX(usageKey), olxFromServer); - // Reload the other data for this component: invalidateComponentData(queryClient, contentLibraryId, usageKey); - // And the description and display name etc. may have changed, so refresh everything in the library too: - queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibrary(contentLibraryId) }); - queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, contentLibraryId) }); }, }); };