Maintain book selections when switching between table and grid views (#1651)

This commit is contained in:
Muppetteer
2025-11-28 09:31:01 -07:00
committed by GitHub
parent 3a291f7770
commit 721952a679
2 changed files with 4 additions and 0 deletions
@@ -242,6 +242,7 @@
@if (currentViewMode === 'table' && books.length > 0) {
<app-book-table
[books]="books"
[preselectedBookIds]="selectedBooks"
(selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="this.bookSorter.selectedSort!"
[visibleColumns]="visibleColumns"
@@ -42,6 +42,7 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
@Input() books: Book[] = [];
@Input() sortOption: SortOption | null = null;
@Input() visibleColumns: any[] = [];
@Input() preselectedBookIds = new Set<number>();
protected urlHelper = inject(UrlHelperService);
private bookService = inject(BookService);
@@ -89,6 +90,8 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
this.metadataCenterViewMode = userState?.user?.userSettings.metadataCenterViewMode ?? 'route';
});
this.selectedBookIds = this.preselectedBookIds;
this.selectedBooks = this.bookService.getBooksByIdsFromState([...this.selectedBookIds]);
this.setScrollHeight();
window.addEventListener('resize', this.setScrollHeight.bind(this));
}