Feature: Add support for recording when a book is finished, so that users can create Magic Shelves based on this information. (#803)
* Added migration for new field in user_book_progress table * Added ability to set date finished when book status changes to read, and reset date finished when book status changes to another value * Added ability to use date published in a Magic Shelf
This commit is contained in:
@@ -21,6 +21,7 @@ export interface Book {
|
||||
seriesCount?: number | null;
|
||||
metadataMatchScore?: number | null;
|
||||
readStatus?: ReadStatus;
|
||||
dateFinished?: string;
|
||||
libraryPath?: { id: number };
|
||||
}
|
||||
|
||||
|
||||
@@ -408,16 +408,12 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
updateBookReadStatus(bookIds: number | number[], status: ReadStatus): Observable<void> {
|
||||
updateBookReadStatus(bookIds: number | number[], status: ReadStatus): Observable<Book[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
return this.http.put<void>(`${this.url}/read-status`, {ids, status}).pipe(
|
||||
tap(() => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
if (!currentState.books) return;
|
||||
const updatedBooks = currentState.books.map(book =>
|
||||
ids.includes(book.id) ? {...book, readStatus: status} : book
|
||||
);
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
return this.http.put<Book[]>(`${this.url}/read-status`, {ids, status}).pipe(
|
||||
tap(updatedBooks => {
|
||||
// Update the books in the state with the actual response from the API
|
||||
updatedBooks.forEach(updatedBook => this.handleBookUpdate(updatedBook));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user