Fix stupid ass bug

This commit is contained in:
aditya.chandel
2025-01-16 22:00:42 -07:00
parent ae2294109b
commit 289b6aff36
3 changed files with 21 additions and 26 deletions
@@ -141,10 +141,10 @@ public class AmazonBookParser implements BookParser {
private String buildQueryUrl(FetchMetadataRequest fetchMetadataRequest, Book book) {
StringBuilder queryBuilder = new StringBuilder(BASE_SEARCH_URL);
// Always add ISBN if present
/*// Always add ISBN if present
if (fetchMetadataRequest.getIsbn() != null && !fetchMetadataRequest.getIsbn().isEmpty()) {
queryBuilder.append("&field-isbn=").append(fetchMetadataRequest.getIsbn());
}
}*/
// Add title if present, otherwise check filename if title is absent
String title = fetchMetadataRequest.getTitle();
@@ -88,12 +88,6 @@ export class BookService {
this.bookStateSubject.next({...currentState, books: updatedBooks});
}
getBookById(bookId: number): Observable<Book | undefined> {
return this.bookState$.pipe(
map(state => state.books?.find(book => book.id === bookId))
);
}
getBookSetting(bookId: number): Observable<BookSetting> {
return this.http.get<BookSetting>(`${this.url}/${bookId}/viewer-setting`);
}
@@ -116,25 +110,26 @@ export class BookService {
}
readBook(bookId: number): void {
this.getBookById(bookId).subscribe((book) => {
if (book) {
if (book.bookType === "PDF") {
const url = `/pdf-viewer/book/${book.id}`;
window.open(url, '_blank');
this.updateLastReadTime(book.id).subscribe({
next: () => {},
error: err => console.error('Failed to update last read time', err),
});
} else if (book.bookType === "EPUB") {
const url = `/epub-viewer/book/${book.id}`;
window.open(url, '_blank');
} else {
console.error('Unsupported book type:', book.bookType);
}
const currentBooks = this.bookStateSubject.value.books;
const book = currentBooks?.find(book => book.id === bookId);
if (book) {
if (book.bookType === "PDF") {
const url = `/pdf-viewer/book/${book.id}`;
window.open(url, '_blank');
this.updateLastReadTime(book.id).subscribe({
next: () => {
},
error: err => console.error('Failed to update last read time', err),
});
} else if (book.bookType === "EPUB") {
const url = `/epub-viewer/book/${book.id}`;
window.open(url, '_blank');
} else {
console.error('Book not found');
console.error('Unsupported book type:', book.bookType);
}
});
} else {
console.error('Book not found');
}
}
searchBooks(query: string): Observable<Book[]> {
@@ -9,7 +9,7 @@
<p-button
#menubutton
icon="pi pi-arrow-left"
icon="pi pi-bars"
[rounded]="true"
[outlined]="true"
(click)="toggleMenu()"