Feature/update date finished date (#873)
* Fixed issue with not updating the book finished date when updating read status * Added ability to set a date finished after setting the book status to Read. --------- Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com>
This commit is contained in:
co-authored by
Aditya Chandel
parent
7a859a7536
commit
53aae8bb42
@@ -319,6 +319,31 @@ export class BookService {
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
}
|
||||
|
||||
updateDateFinished(bookId: number, dateFinished: string | null): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
dateFinished: dateFinished
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body).pipe(
|
||||
tap(() => {
|
||||
// Update the book in the state
|
||||
const currentState = this.bookStateSubject.value;
|
||||
if (currentState.books) {
|
||||
const updatedBooks = currentState.books.map(book => {
|
||||
if (book.id === bookId) {
|
||||
return { ...book, dateFinished: dateFinished || undefined };
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateSubject.next({
|
||||
...currentState,
|
||||
books: updatedBooks
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
regenerateCovers(): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/regenerate-covers`, {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user