mirror of
https://github.com/adityachandelgit/BookLore.git
synced 2026-03-16 16:42:08 -05:00
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:
+23
-15
@@ -256,15 +256,15 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
|
||||
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
|
||||
.subscribe(userState => {
|
||||
this.metadataMenuItems = this.bookMenuService.getMetadataMenuItems(
|
||||
() => this.autoFetchMetadata(),
|
||||
() => this.fetchMetadata(),
|
||||
() => this.bulkEditMetadata(),
|
||||
() => this.multiBookEditMetadata(),
|
||||
() => this.regenerateCoversForSelected(),
|
||||
userState.user
|
||||
);
|
||||
});
|
||||
this.metadataMenuItems = this.bookMenuService.getMetadataMenuItems(
|
||||
() => this.autoFetchMetadata(),
|
||||
() => this.fetchMetadata(),
|
||||
() => this.bulkEditMetadata(),
|
||||
() => this.multiBookEditMetadata(),
|
||||
() => this.regenerateCoversForSelected(),
|
||||
userState.user
|
||||
);
|
||||
});
|
||||
|
||||
this.bulkReadActionsMenuItems = this.bookMenuService.getBulkReadActionsMenu(this.selectedBooks, this.user());
|
||||
|
||||
@@ -476,18 +476,18 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
if (selected) {
|
||||
if (book.seriesBooks) {
|
||||
//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 {
|
||||
this.selectedBooks.add(book.id);
|
||||
this.selectedBooks.add(book.id);
|
||||
}
|
||||
} else {
|
||||
if (book.seriesBooks) {
|
||||
//it is a series
|
||||
book.seriesBooks.forEach(book =>{
|
||||
book.seriesBooks.forEach(book => {
|
||||
this.selectedBooks.delete(book.id);
|
||||
});
|
||||
} else {
|
||||
this.selectedBooks.delete(book.id);
|
||||
this.selectedBooks.delete(book.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -557,7 +557,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
this.selectedBooks.clear();
|
||||
});
|
||||
},
|
||||
reject: () => {}
|
||||
reject: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -656,6 +657,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
|
||||
openShelfAssigner(): void {
|
||||
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
|
||||
if (this.dynamicDialogRef) {
|
||||
this.dynamicDialogRef.onClose.subscribe(result => {
|
||||
if (result.assigned) {
|
||||
this.selectedBooks.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
lockUnlockMetadata(): void {
|
||||
@@ -709,7 +717,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-3
@@ -74,11 +74,11 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'});
|
||||
this.dynamicDialogRef.close();
|
||||
this.dynamicDialogRef.close({assigned: true});
|
||||
},
|
||||
error: () => {
|
||||
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 {
|
||||
this.dynamicDialogRef.close();
|
||||
this.dynamicDialogRef.close({assigned: false});
|
||||
}
|
||||
|
||||
isShelfSelected(shelf: Shelf): boolean {
|
||||
|
||||
Reference in New Issue
Block a user