fix(ui): fix metadata lock patch (#1265)
This commit is contained in:
+2
-2
@@ -43,10 +43,10 @@ describe('BookTableComponent', () => {
|
||||
let component: BookTableComponent;
|
||||
let bookSelectionService: BookSelectionService;
|
||||
let bookMetadataManageService: { toggleAllLock: ReturnType<typeof vi.fn> };
|
||||
let queryClient: { setQueriesData: ReturnType<typeof vi.fn> };
|
||||
let queryClient: { setQueryData: ReturnType<typeof vi.fn>; setQueriesData: ReturnType<typeof vi.fn> };
|
||||
|
||||
beforeEach(() => {
|
||||
queryClient = {setQueriesData: vi.fn()};
|
||||
queryClient = {setQueryData: vi.fn(), setQueriesData: vi.fn()};
|
||||
bookMetadataManageService = {
|
||||
toggleAllLock: vi.fn(() => of(null)),
|
||||
};
|
||||
|
||||
@@ -131,6 +131,21 @@ export function patchAppBooksCoverInCache(
|
||||
}
|
||||
|
||||
export function patchAppBooksMetadataLockInCache(queryClient: QueryClient, bookId: number, allMetadataLocked: boolean): void {
|
||||
// Do not create the legacy full-books cache when only the paginated app-books cache exists.
|
||||
queryClient.setQueryData<Book[]>(BOOKS_QUERY_KEY, current =>
|
||||
current?.map(book =>
|
||||
book.id === bookId
|
||||
? {
|
||||
...book,
|
||||
metadata: {
|
||||
...(book.metadata ?? {bookId}),
|
||||
allMetadataLocked,
|
||||
},
|
||||
}
|
||||
: book
|
||||
) ?? current
|
||||
);
|
||||
|
||||
queryClient.setQueriesData<InfiniteData<AppPageResponse<AppBookSummary>>>(
|
||||
{queryKey: APP_BOOKS_QUERY_PREFIX},
|
||||
current => {
|
||||
|
||||
Reference in New Issue
Block a user