automatically set library/path if there is only one option available

This commit is contained in:
Ionuț Staicu
2025-08-12 17:41:27 +03:00
parent ace5849afa
commit 9e1d437e74
@@ -44,9 +44,21 @@ interface UploadingFile {
export class BookUploaderComponent implements OnInit {
files: UploadingFile[] = [];
isUploading: boolean = false;
selectedLibrary: Library | null = null;
_selectedLibrary: Library | null = null;
selectedPath: LibraryPath | null = null;
get selectedLibrary(): Library | null {
return this._selectedLibrary;
}
set selectedLibrary(library: Library | null) {
this._selectedLibrary = library;
if(library?.paths?.length === 1) {
this.selectedPath = library.paths[0];
}
}
private readonly libraryService = inject(LibraryService);
private readonly messageService = inject(MessageService);
private readonly appSettingsService = inject(AppSettingsService);
@@ -70,6 +82,15 @@ export class BookUploaderComponent implements OnInit {
.subscribe(settings => {
this.maxFileSizeBytes = (settings?.maxFileUploadSizeInMb ?? 100) * 1024 * 1024;
});
this.libraryState$.subscribe(state => {
if (state?.libraries?.length !== 1 || this.selectedLibrary) {
return;
}
this.selectedLibrary = state.libraries[0];
});
}
hasPendingFiles(): boolean {