refactor(books): migrate services off the old book cache (#2218)
This commit is contained in:
@@ -10,7 +10,7 @@ import {CacheStorageService} from '../../../shared/service/cache-storage.service
|
||||
import {LocalSettingsService} from '../../../shared/service/local-settings.service';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||
import {patchBookInCacheWith, patchBooksInCache, removeBooksFromCache} from './book-query-cache';
|
||||
import {patchAttachedBookFilesInCache, patchBookInCacheWith, upsertBooksInCache} from './legacy-book-cache';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -168,7 +168,7 @@ export class BookFileService {
|
||||
detachBookFile(bookId: number, fileId: number, copyMetadata: boolean): Observable<DetachBookFileResponse> {
|
||||
return this.http.post<DetachBookFileResponse>(`${this.url}/${bookId}/files/${fileId}/detach`, {copyMetadata}).pipe(
|
||||
tap(response => {
|
||||
patchBooksInCache(this.queryClient, [response.sourceBook, response.newBook]);
|
||||
upsertBooksInCache(this.queryClient, [response.sourceBook, response.newBook]);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('metadata.viewer.toast.detachFileSuccessSummary'),
|
||||
@@ -196,8 +196,11 @@ export class BookFileService {
|
||||
moveFiles
|
||||
}).pipe(
|
||||
tap(response => {
|
||||
patchBooksInCache(this.queryClient, [response.updatedBook]);
|
||||
removeBooksFromCache(this.queryClient, response.deletedSourceBookIds);
|
||||
patchAttachedBookFilesInCache(
|
||||
this.queryClient,
|
||||
response.updatedBook,
|
||||
response.deletedSourceBookIds,
|
||||
);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('book.bookService.toast.filesAttachedSummary'),
|
||||
|
||||
Reference in New Issue
Block a user