perf(frontend): optimize initial bundle size with lazy-loaded dialogs and localized chart providers (#1110)

This commit is contained in:
brios
2026-05-18 23:05:10 +02:00
committed by GitHub
parent 4afc738dd4
commit c6cbdcfa11
32 changed files with 532 additions and 405 deletions
@@ -1114,8 +1114,8 @@ export class MetadataEditorComponent implements OnInit {
this.closeDialogButtonClicked.emit();
}
openCoverSearch() {
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'ebook');
async openCoverSearch() {
const ref = await this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'ebook');
ref?.onClose.pipe(
take(1),
filter(result => !!result),
@@ -1204,8 +1204,8 @@ export class MetadataEditorComponent implements OnInit {
return this.bookMetadataManageService.getUploadAudiobookCoverUrl(this.currentBookId);
}
openAudiobookCoverSearch() {
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'audiobook');
async openAudiobookCoverSearch() {
const ref = await this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'audiobook');
ref?.onClose.pipe(
take(1),
filter(result => !!result),
@@ -67,11 +67,11 @@ describe('MetadataViewerComponent', () => {
const deleteBookFile = vi.fn(() => of(void 0));
const detachBookFile = vi.fn(() => of(void 0));
const openAdditionalFileUploaderDialog = vi.fn();
const openCustomSendDialog = vi.fn();
const openBookFileAttacherDialog = vi.fn();
const openFileMoverDialog = vi.fn();
const openShelfAssignerDialog = vi.fn();
const openAdditionalFileUploaderDialog = vi.fn(() => Promise.resolve(null));
const openCustomSendDialog = vi.fn(() => Promise.resolve(null));
const openBookFileAttacherDialog = vi.fn(() => Promise.resolve(null));
const openFileMoverDialog = vi.fn(() => Promise.resolve(null));
const openShelfAssignerDialog = vi.fn(() => Promise.resolve(null));
const emailBookQuick = vi.fn(() => of(void 0));
const refreshMetadataTask = vi.fn(() => of(void 0));
@@ -214,7 +214,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
items.push({
label: this.t.translate('metadata.viewer.menuShelf'),
icon: 'pi pi-folder',
command: () => this.assignShelf(book.id)
command: () => {
void this.assignShelf(book).catch(() => undefined);
}
});
if (permissions?.canManageLibrary || permissions?.admin) {
@@ -235,7 +237,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
label: this.t.translate('metadata.viewer.menuUploadFile'),
icon: 'pi pi-upload',
command: () => {
this.bookDialogHelperService.openAdditionalFileUploaderDialog(book);
void this.bookDialogHelperService.openAdditionalFileUploaderDialog(book).catch(() => undefined);
},
});
}
@@ -247,7 +249,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
label: this.t.translate('metadata.viewer.menuOrganizeFiles'),
icon: 'pi pi-arrows-h',
command: () => {
this.openFileMoverDialog(book.id);
void this.openFileMoverDialog(book.id).catch(() => undefined);
},
});
}
@@ -266,7 +268,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
label: this.t.translate('metadata.viewer.menuCustomSend'),
icon: 'pi pi-cog',
command: () => {
this.bookDialogHelperService.openCustomSendDialog(book);
void this.bookDialogHelperService.openCustomSendDialog(book).catch(() => undefined);
}
}
]
@@ -281,7 +283,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
label: this.t.translate('metadata.viewer.menuAttachToAnotherBook'),
icon: 'pi pi-link',
command: () => {
this.bookDialogHelperService.openBookFileAttacherDialog(book);
void this.bookDialogHelperService.openBookFileAttacherDialog(book).catch(() => undefined);
},
});
}
@@ -687,8 +689,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
}
}
assignShelf(bookId: number) {
this.bookDialogHelperService.openShelfAssignerDialog((this.bookService.findBookById(bookId) as Book), null);
async assignShelf(book: Book) {
await this.bookDialogHelperService.openShelfAssignerDialog(book, null);
}
updateReadStatus(status: ReadStatus): void {
@@ -1251,8 +1253,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
this.editDateFinished = null;
}
openFileMoverDialog(bookId: number): void {
this.bookDialogHelperService.openFileMoverDialog(new Set([bookId]));
async openFileMoverDialog(bookId: number) {
await this.bookDialogHelperService.openFileMoverDialog(new Set([bookId]));
}
protected readonly ResetProgressTypes = ResetProgressTypes;