Warn on Refresh Metadata (#610)

* Warn the user about the dangers of refresh metadata and promote them to use a scan instead.

* Removed presence hub and moved it over to message hub.

When a library scan is in progress, now a spinner will show on manage libraries page.

* Code cleanup
This commit is contained in:
Joseph Milazzo 2021-09-30 17:36:58 -07:00 committed by GitHub
parent 9b536ce700
commit 0ac54e682f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 101 additions and 77 deletions

View file

@ -6,6 +6,7 @@ import { take } from 'rxjs/operators';
import { BookmarksModalComponent } from '../cards/_modals/bookmarks-modal/bookmarks-modal.component';
import { AddToListModalComponent, ADD_FLOW } from '../reading-list/_modals/add-to-list-modal/add-to-list-modal.component';
import { EditReadingListModalComponent } from '../reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component';
import { ConfirmService } from '../shared/confirm.service';
import { Chapter } from '../_models/chapter';
import { Library } from '../_models/library';
import { ReadingList } from '../_models/reading-list';
@ -35,7 +36,8 @@ export class ActionService implements OnDestroy {
private readingListModalRef: NgbModalRef | null = null;
constructor(private libraryService: LibraryService, private seriesService: SeriesService,
private readerService: ReaderService, private toastr: ToastrService, private modalService: NgbModal) { }
private readerService: ReaderService, private toastr: ToastrService, private modalService: NgbModal,
private confirmService: ConfirmService) { }
ngOnDestroy() {
this.onDestroy.next();
@ -66,11 +68,15 @@ export class ActionService implements OnDestroy {
* @param callback Optional callback to perform actions after API completes
* @returns
*/
refreshMetadata(library: Partial<Library>, callback?: LibraryActionCallback) {
async refreshMetadata(library: Partial<Library>, callback?: LibraryActionCallback) {
if (!library.hasOwnProperty('id') || library.id === undefined) {
return;
}
if (!await this.confirmService.confirm('Refresh metadata will force all cover images and metadata to be recalculated. This is a heavy operation. Are you sure you don\'t want to perform a Scan instead?')) {
return;
}
this.libraryService.refreshMetadata(library?.id).pipe(take(1)).subscribe((res: any) => {
this.toastr.success('Scan started for ' + library.name);
if (callback) {
@ -128,7 +134,11 @@ export class ActionService implements OnDestroy {
* @param series Series, must have libraryId, id and name populated
* @param callback Optional callback to perform actions after API completes
*/
refreshMetdata(series: Series, callback?: SeriesActionCallback) {
async refreshMetdata(series: Series, callback?: SeriesActionCallback) {
if (!await this.confirmService.confirm('Refresh metadata will force all cover images and metadata to be recalculated. This is a heavy operation. Are you sure you don\'t want to perform a Scan instead?')) {
return;
}
this.seriesService.refreshMetadata(series).pipe(take(1)).subscribe((res: any) => {
this.toastr.success('Refresh started for ' + series.name);
if (callback) {