New subscribe pattern

This commit is contained in:
aditya.chandel
2025-01-13 11:57:50 -07:00
parent 2cbf49a5e6
commit b0cd19189b
4 changed files with 42 additions and 42 deletions
@@ -43,8 +43,7 @@
<div class="book-card-container" *ngIf="bookState?.books as books">
<app-book-table *ngIf="value === 'table'&& books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort"></app-book-table>
<app-book-table *ngIf="value === 'table'&& books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)" [sortOption]="selectedSort"></app-book-table>
<virtual-scroller *ngIf="value === 'grid'" class="virtual-scroller" #scroll [items]="books">
<div class="grid grid-cols-12 gap-4" #container>
@@ -269,12 +269,14 @@ export class BookBrowserComponent implements OnInit {
unshelfBooks() {
if (this.entity) {
this.bookService.updateBookShelves(this.selectedBooks, new Set(), new Set([this.entity.id])).subscribe(
() => {
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Books shelves updated'});
this.selectedBooks = new Set<number>();
},
() => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update books shelves'});
{
next: () => {
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Books shelves updated'});
this.selectedBooks = new Set<number>();
},
error: () => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update books shelves'});
}
}
);
}