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) { private String buildQueryUrl(FetchMetadataRequest fetchMetadataRequest, Book book) {
StringBuilder queryBuilder = new StringBuilder(BASE_SEARCH_URL); StringBuilder queryBuilder = new StringBuilder(BASE_SEARCH_URL);
// Always add ISBN if present /*// Always add ISBN if present
if (fetchMetadataRequest.getIsbn() != null && !fetchMetadataRequest.getIsbn().isEmpty()) { if (fetchMetadataRequest.getIsbn() != null && !fetchMetadataRequest.getIsbn().isEmpty()) {
queryBuilder.append("&field-isbn=").append(fetchMetadataRequest.getIsbn()); queryBuilder.append("&field-isbn=").append(fetchMetadataRequest.getIsbn());
} }*/
// Add title if present, otherwise check filename if title is absent // Add title if present, otherwise check filename if title is absent
String title = fetchMetadataRequest.getTitle(); String title = fetchMetadataRequest.getTitle();
@@ -88,12 +88,6 @@ export class BookService {
this.bookStateSubject.next({...currentState, books: updatedBooks}); 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> { getBookSetting(bookId: number): Observable<BookSetting> {
return this.http.get<BookSetting>(`${this.url}/${bookId}/viewer-setting`); return this.http.get<BookSetting>(`${this.url}/${bookId}/viewer-setting`);
} }
@@ -116,25 +110,26 @@ export class BookService {
} }
readBook(bookId: number): void { readBook(bookId: number): void {
this.getBookById(bookId).subscribe((book) => { const currentBooks = this.bookStateSubject.value.books;
if (book) { const book = currentBooks?.find(book => book.id === bookId);
if (book.bookType === "PDF") { if (book) {
const url = `/pdf-viewer/book/${book.id}`; if (book.bookType === "PDF") {
window.open(url, '_blank'); const url = `/pdf-viewer/book/${book.id}`;
this.updateLastReadTime(book.id).subscribe({ window.open(url, '_blank');
next: () => {}, this.updateLastReadTime(book.id).subscribe({
error: err => console.error('Failed to update last read time', err), next: () => {
}); },
} else if (book.bookType === "EPUB") { error: err => console.error('Failed to update last read time', err),
const url = `/epub-viewer/book/${book.id}`; });
window.open(url, '_blank'); } else if (book.bookType === "EPUB") {
} else { const url = `/epub-viewer/book/${book.id}`;
console.error('Unsupported book type:', book.bookType); window.open(url, '_blank');
}
} else { } else {
console.error('Book not found'); console.error('Unsupported book type:', book.bookType);
} }
}); } else {
console.error('Book not found');
}
} }
searchBooks(query: string): Observable<Book[]> { searchBooks(query: string): Observable<Book[]> {
@@ -9,7 +9,7 @@
<p-button <p-button
#menubutton #menubutton
icon="pi pi-arrow-left" icon="pi pi-bars"
[rounded]="true" [rounded]="true"
[outlined]="true" [outlined]="true"
(click)="toggleMenu()" (click)="toggleMenu()"