refactor(ui): move large library processing screen to notifications (#1428)
Co-authored-by: Alex <25013571+alexhb1@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import {parseLogNotification} from './shared/websocket/model/log-notification.mo
|
||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {Toast} from 'primeng/toast';
|
||||
import {RouterOutlet} from '@angular/router';
|
||||
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {AuthInitializationService} from './core/security/auth-initialization-service';
|
||||
import {AppConfigService} from './shared/service/app-config.service';
|
||||
import {MetadataBatchProgressNotification} from './shared/model/metadata-batch-progress.model';
|
||||
@@ -14,13 +14,11 @@ import {MetadataProgressService} from './shared/service/metadata-progress.servic
|
||||
import {BookdropFileNotification, BookdropFileService} from './features/bookdrop/service/bookdrop-file.service';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {TaskProgressPayload, TaskService} from './features/settings/task-management/task.service';
|
||||
import {LibraryService} from './features/book/service/library.service';
|
||||
import {LibraryHealthService} from './features/book/service/library-health.service';
|
||||
import {LibraryLoadingService} from './features/library-creator/library-loading.service';
|
||||
import {scan} from 'rxjs/operators';
|
||||
import {AuthService} from './shared/service/auth.service';
|
||||
import {CommandPaletteComponent} from './features/command-palette/command-palette.component';
|
||||
import {CommandPaletteService} from './features/command-palette/command-palette.service';
|
||||
import {LibraryImportProgressService} from './shared/service/library-import-progress.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@@ -44,11 +42,11 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
private metadataProgressService = inject(MetadataProgressService);
|
||||
private bookdropFileService = inject(BookdropFileService);
|
||||
private taskService = inject(TaskService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private libraryHealthService = inject(LibraryHealthService);
|
||||
private libraryLoadingService = inject(LibraryLoadingService);
|
||||
private authService = inject(AuthService);
|
||||
private commandPaletteService = inject(CommandPaletteService);
|
||||
private readonly libraryImportProgressService = inject(LibraryImportProgressService);
|
||||
private readonly translocoService = inject(TranslocoService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly syncAuthInitializationEffect = effect(() => {
|
||||
const ready = this.authInit.initialized();
|
||||
@@ -107,25 +105,11 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
|
||||
private setupWebSocketSubscriptions(): void {
|
||||
this.subscriptions.push(
|
||||
this.rxStompService.watch('/user/queue/book-add').pipe(
|
||||
scan((acc, msg) => {
|
||||
const loadingState = this.libraryService.largeLibraryLoading();
|
||||
const book = JSON.parse(msg.body);
|
||||
if (loadingState.isLoading) {
|
||||
const newCount = acc.count + 1;
|
||||
this.libraryLoadingService.showBookLoadingProgress(book.metadata?.title || 'Unknown Book', newCount, loadingState.expectedCount);
|
||||
this.bookService.handleNewlyCreatedBook(book);
|
||||
if (newCount >= loadingState.expectedCount) {
|
||||
this.libraryService.setLargeLibraryLoading(false, 0);
|
||||
return {count: 0};
|
||||
}
|
||||
return {count: newCount};
|
||||
} else {
|
||||
this.bookService.handleNewlyCreatedBook(book);
|
||||
return {count: 0};
|
||||
}
|
||||
}, {count: 0})
|
||||
).subscribe()
|
||||
this.rxStompService.watch('/user/queue/book-add').subscribe(msg => {
|
||||
const book = JSON.parse(msg.body);
|
||||
this.libraryImportProgressService.recordBookAdded(book.metadata?.title || this.translocoService.translate('book.unknownTitle'));
|
||||
this.bookService.handleNewlyCreatedBook(book);
|
||||
})
|
||||
);
|
||||
this.subscriptions.push(
|
||||
this.rxStompService.watch('/user/queue/book-update').subscribe(msg =>
|
||||
@@ -186,6 +170,5 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
window.removeEventListener('online', this.onOnline);
|
||||
window.removeEventListener('offline', this.onOffline);
|
||||
this.subscriptions.forEach(sub => sub.unsubscribe());
|
||||
this.libraryLoadingService.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user