From f10ad9f5259d079313e2fb77b3925d92bdaff69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Mon, 4 Nov 2024 13:56:20 -0300 Subject: [PATCH] fix: enable publish button on library after component edit [sumac] [FC-0062] (#1447) This PR fixes the following bug: After publishing a library then editing a component, the "Publish" button in Library Info doesn't become enabled until you refresh Fixes: https://github.com/openedx/frontend-app-authoring/issues/1455 Backport: https://github.com/openedx/frontend-app-authoring/pull/1446 --- src/library-authoring/data/apiHooks.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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) }); }, }); };