fix(metadata): refactor book metadata fetching to use fetch API and signals for state management (#495)

* fix(metadata): refactor book metadata fetching to use fetch API and signals for state management

* fix(metadata): update tests to mock fetch API for book metadata streaming

* fix(metadata): improve metadata fetching with error handling and retry logic

* fix(metadata): update author photo search to use SSE with auth headers and improve error handling

* fix(metadata): require bookId for cover fetching and improve error handling

* fix(metadata): simplify error handling in DuckDuckGo cover image fetching

* fix(metadata): refactor SSE data handling for cover image and book metadata fetching
This commit is contained in:
brios
2026-04-22 17:27:15 -04:00
committed by Zach Yale
parent 27db18ae80
commit fcee609b15
19 changed files with 702 additions and 397 deletions
@@ -80,23 +80,26 @@ export class CoverSearchComponent implements OnInit {
onSearch() {
if (this.searchForm.valid) {
this.loading = true;
this.coverImages = [];
const request: CoverFetchRequest = {
bookId: this.bookId,
title: this.searchForm.value.title,
author: this.searchForm.value.author,
coverType: this.coverType
};
this.bookCoverService.fetchBookCovers(request)
.pipe(finalize(() => this.loading = false))
.pipe(finalize(() => {
this.loading = false;
this.hasSearched = true;
}))
.subscribe({
next: (images) => {
this.coverImages = images.sort((a, b) => a.index - b.index);
this.hasSearched = true;
next: (image) => {
this.coverImages.push(image);
this.coverImages.sort((a, b) => a.index - b.index);
},
error: (error) => {
console.error('Error fetching covers:', error);
this.coverImages = [];
this.hasSearched = true;
}
});
} else {