Fix last read
This commit is contained in:
+1
-8
@@ -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);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user