Fix: regenerate improvements (#1981)

* chore: report error on cover regeneration fail

* refactor: use RxJS forkJoin instead of Promise.all

- Replace Promise-based approach with RxJS forkJoin for better consistency
- Remove console.log debug statement
- Improve error handling with proper RxJS operators

Co-authored-by: farfromrefug <655344+farfromrefug@users.noreply.github.com>

* chore: cleanup

* chore: rework per development upstream

* chore: updating books on bulk cover regenerate

* chore: working

* chore: metadata regenerateCover pdate UI

* chore: review per comments

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
farfromrefuge
2025-12-25 10:09:33 -07:00
committed by GitHub
co-authored by farfromrefug copilot-swe-agent[bot]
parent 77e06b868e
commit f5e99d52c1
8 changed files with 84 additions and 18 deletions
@@ -5,7 +5,7 @@ import {PageTitleService} from "../../../../shared/service/page-title.service";
import {LibraryService} from '../../service/library.service';
import {BookService} from '../../service/book.service';
import {catchError, debounceTime, filter, map, switchMap, take} from 'rxjs/operators';
import {BehaviorSubject, combineLatest, finalize, Observable, of, Subject} from 'rxjs';
import {BehaviorSubject, combineLatest, finalize, forkJoin, Observable, of, Subject} from 'rxjs';
import {ShelfService} from '../../service/shelf.service';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {Library} from '../../model/library.model';
@@ -696,7 +696,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
life: 3000
});
}
});
});
}
});
}
@@ -632,6 +632,24 @@ export class BookService {
this.bookStateSubject.next({...currentState, books: updatedBooks})
}
/**
* Incoming payload: [{ id: number, coverUpdatedOn: "2025-12-25T00:48:17Z" }, ...]
* Apply minimal patch to local state so UI updates the cover image (and can use cache-busting).
*/
handleMultipleBookCoverPatches(patches: { id: number; coverUpdatedOn: string }[]): void {
if (!patches || patches.length === 0) return;
const currentState = this.bookStateSubject.value;
const books = currentState.books || [];
patches.forEach(p => {
const index = books.findIndex(b=>b.id === p.id);
if (index !== -1 && books[index].metadata) {
books[index].metadata.coverUpdatedOn = p.coverUpdatedOn;
}
});
this.bookStateSubject.next({...currentState, books});
}
toggleFieldLocks(bookIds: number[] | Set<number>, fieldActions: Record<string, 'LOCK' | 'UNLOCK'>): Observable<void> {
const bookIdSet = bookIds instanceof Set ? bookIds : new Set(bookIds);