automatically set library/path if there is only one option available
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user