Skip to content

Commit abcef4a

Browse files
fix: refresh search token after library (#2924)
creation for course creator access When a course creator creates a new library, the cached JWT token for Meilisearch needs to be refreshed to include the new library's access_id. Without this, newly added components won't appear in search results until the page is refreshed. This works in conjunction with the backend fix that creates SearchAccess records immediately on library creation. The fix invalidates the content_search query, triggering React Query to refetch the token with updated access permissions.
1 parent 5c1cdcf commit abcef4a

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/library-authoring/create-library/data/apiHooks.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ describe('create library apiHooks', () => {
6363
expect(invalidateQueriesSpy).toHaveBeenCalledWith({
6464
queryKey: libraryAuthoringQueryKeys.contentLibraryList(),
6565
});
66+
expect(invalidateQueriesSpy).toHaveBeenCalledWith({
67+
queryKey: ['content_search'],
68+
});
6669
});
6770
});
6871

src/library-authoring/create-library/data/apiHooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const useCreateLibraryV2 = () => {
2323
mutationFn: createLibraryV2,
2424
onSettled: () => {
2525
queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.contentLibraryList() });
26+
// Invalidate the search token to refresh with the new library's access_id
27+
queryClient.invalidateQueries({ queryKey: ['content_search'] });
2628
},
2729
});
2830
};

0 commit comments

Comments
 (0)