Add book count to menu
This commit is contained in:
@@ -76,4 +76,10 @@ export class LibraryService {
|
||||
return this.http.get<BookWithNeighborsDTO>(`${this.url}/${libraryId}/book/${bookId}/withNeighbors`);
|
||||
}
|
||||
|
||||
getBookCount(libraryId: number): Observable<number> {
|
||||
return this.bookService.books$.pipe(
|
||||
map(books => books.filter(book => book.libraryId === libraryId).length)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,4 +66,10 @@ export class ShelfService {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getBookCount(shelfId: number): Observable<number> {
|
||||
return this.bookService.books$.pipe(
|
||||
map(books => books.filter(book => book.shelves?.some(shelf => shelf.id === shelfId)).length)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user