Fix last read

This commit is contained in:
aditya.chandel
2025-10-27 23:01:17 -06:00
parent cd0ca7ffa8
commit 3155a3666a
@@ -72,19 +72,12 @@ export class MainDashboardComponent implements OnInit {
private getLastReadBooks(maxItems: number, sortBy?: string): Observable<Book[]> { private getLastReadBooks(maxItems: number, sortBy?: string): Observable<Book[]> {
return this.bookService.bookState$.pipe( return this.bookService.bookState$.pipe(
map((state: BookState) => { map((state: BookState) => {
let books = (state.books || []).filter(book => let books = (state.books || []).filter(book => book.lastReadTime);
book.lastReadTime &&
(book.readStatus === ReadStatus.READING ||
book.readStatus === ReadStatus.RE_READING ||
book.readStatus === ReadStatus.PAUSED)
);
books = books.sort((a, b) => { books = books.sort((a, b) => {
const aTime = new Date(a.lastReadTime!).getTime(); const aTime = new Date(a.lastReadTime!).getTime();
const bTime = new Date(b.lastReadTime!).getTime(); const bTime = new Date(b.lastReadTime!).getTime();
return bTime - aTime; return bTime - aTime;
}); });
return books.slice(0, maxItems); return books.slice(0, maxItems);
}) })
); );