Fix: Deselect items when they are removed from current view in book browser (#2093)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-01 13:48:39 -07:00
committed by GitHub
co-authored by acx10
parent 78344d1d0e
commit c7cfe266d4
2 changed files with 26 additions and 18 deletions
@@ -476,14 +476,14 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
if (selected) { if (selected) {
if (book.seriesBooks) { if (book.seriesBooks) {
//it is a series //it is a series
this.selectedBooks = new Set([...this.selectedBooks, ...book.seriesBooks.map(book=>book.id)]); this.selectedBooks = new Set([...this.selectedBooks, ...book.seriesBooks.map(book => book.id)]);
} else { } else {
this.selectedBooks.add(book.id); this.selectedBooks.add(book.id);
} }
} else { } else {
if (book.seriesBooks) { if (book.seriesBooks) {
//it is a series //it is a series
book.seriesBooks.forEach(book =>{ book.seriesBooks.forEach(book => {
this.selectedBooks.delete(book.id); this.selectedBooks.delete(book.id);
}); });
} else { } else {
@@ -557,7 +557,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.selectedBooks.clear(); this.selectedBooks.clear();
}); });
}, },
reject: () => {} reject: () => {
}
}); });
} }
@@ -656,6 +657,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
openShelfAssigner(): void { openShelfAssigner(): void {
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks); this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
if (this.dynamicDialogRef) {
this.dynamicDialogRef.onClose.subscribe(result => {
if (result.assigned) {
this.selectedBooks.clear();
}
});
}
} }
lockUnlockMetadata(): void { lockUnlockMetadata(): void {
@@ -74,11 +74,11 @@ export class ShelfAssignerComponent implements OnInit {
.subscribe({ .subscribe({
next: () => { next: () => {
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'}); this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'});
this.dynamicDialogRef.close(); this.dynamicDialogRef.close({assigned: true});
}, },
error: () => { error: () => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book shelves'}); this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book shelves'});
this.dynamicDialogRef.close(); this.dynamicDialogRef.close({assigned: false});
} }
}); });
} }
@@ -104,7 +104,7 @@ export class ShelfAssignerComponent implements OnInit {
} }
closeDialog(): void { closeDialog(): void {
this.dynamicDialogRef.close(); this.dynamicDialogRef.close({assigned: false});
} }
isShelfSelected(shelf: Shelf): boolean { isShelfSelected(shelf: Shelf): boolean {