Fix: exclude completed books from Discover Something New (#1598)
This commit is contained in:
+14
-1
@@ -106,7 +106,20 @@ export class MainDashboardComponent implements OnInit {
|
||||
private getRandomBooks(maxItems: number, sortBy?: string): Observable<Book[]> {
|
||||
return this.bookService.bookState$.pipe(
|
||||
map((state: BookState) => {
|
||||
return this.shuffleBooks(state.books || [], maxItems);
|
||||
const excludedStatuses = new Set<ReadStatus>([
|
||||
ReadStatus.READ,
|
||||
ReadStatus.PARTIALLY_READ,
|
||||
ReadStatus.READING,
|
||||
ReadStatus.PAUSED,
|
||||
ReadStatus.WONT_READ,
|
||||
ReadStatus.ABANDONED
|
||||
]);
|
||||
|
||||
const candidates = (state.books || []).filter(book =>
|
||||
!book.readStatus || !excludedStatuses.has(book.readStatus)
|
||||
);
|
||||
|
||||
return this.shuffleBooks(candidates, maxItems);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user