Skip to content

Commit 949e4ac

Browse files
authored
fix: enable publish button on library after component edit [FC-0062] (#1446)
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. Updates the apiHooks to invalidates library query.
1 parent 549dbaa commit 949e4ac

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/library-authoring/data/apiHooks.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export const xblockQueryKeys = {
113113
export function invalidateComponentData(queryClient: QueryClient, contentLibraryId: string, usageKey: string) {
114114
queryClient.invalidateQueries({ queryKey: xblockQueryKeys.xblockFields(usageKey) });
115115
queryClient.invalidateQueries({ queryKey: xblockQueryKeys.componentMetadata(usageKey) });
116+
// The description and display name etc. may have changed, so refresh everything in the library too:
117+
queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibrary(contentLibraryId) });
116118
queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, contentLibraryId) });
117119
}
118120

@@ -150,8 +152,6 @@ export const useDeleteLibraryBlock = () => {
150152
mutationFn: deleteLibraryBlock,
151153
onSettled: (_data, _error, variables) => {
152154
const libraryId = getLibraryId(variables.usageKey);
153-
queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibrary(libraryId) });
154-
queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, libraryId) });
155155
invalidateComponentData(queryClient, libraryId, variables.usageKey);
156156
},
157157
});
@@ -367,11 +367,7 @@ export const useUpdateXBlockOLX = (usageKey: string) => {
367367
mutationFn: (newOLX: string) => setXBlockOLX(usageKey, newOLX),
368368
onSuccess: (olxFromServer) => {
369369
queryClient.setQueryData(xblockQueryKeys.xblockOLX(usageKey), olxFromServer);
370-
// Reload the other data for this component:
371370
invalidateComponentData(queryClient, contentLibraryId, usageKey);
372-
// And the description and display name etc. may have changed, so refresh everything in the library too:
373-
queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibrary(contentLibraryId) });
374-
queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, contentLibraryId) });
375371
},
376372
});
377373
};

0 commit comments

Comments
 (0)