fix: when selecting a series, select all books from the series (#1979)

This commit is contained in:
farfromrefuge
2025-12-25 11:42:30 -07:00
committed by GitHub
parent 811a7e0906
commit 5f2000f085
4 changed files with 32 additions and 24 deletions
@@ -465,14 +465,30 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
); );
} }
onCheckboxClicked(event: { index: number; bookId: number; selected: boolean; shiftKey: boolean }) { handleBookSelection(book: Book, selected: boolean) {
const {index, bookId, selected, shiftKey} = event;
if (!shiftKey || this.lastSelectedIndex === null) {
if (selected) { if (selected) {
this.selectedBooks.add(bookId); if (book.seriesBooks) {
//it is a series
this.selectedBooks = new Set([...this.selectedBooks, ...book.seriesBooks.map(book=>book.id)]);
} else { } else {
this.selectedBooks.delete(bookId); this.selectedBooks.add(book.id);
} }
} else {
if (book.seriesBooks) {
//it is a series
book.seriesBooks.forEach(book =>{
this.selectedBooks.delete(book.id);
});
} else {
this.selectedBooks.delete(book.id);
}
}
}
onCheckboxClicked(event: { index: number; book: Book; selected: boolean; shiftKey: boolean }) {
const {index, book, selected, shiftKey} = event;
if (!shiftKey || this.lastSelectedIndex === null) {
this.handleBookSelection(book, selected);
this.lastSelectedIndex = index; this.lastSelectedIndex = index;
} else { } else {
const start = Math.min(this.lastSelectedIndex, index); const start = Math.min(this.lastSelectedIndex, index);
@@ -481,23 +497,14 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
for (let i = start; i <= end; i++) { for (let i = start; i <= end; i++) {
const book = this.currentBooks[i]; const book = this.currentBooks[i];
if (!book) continue; if (!book) continue;
this.handleBookSelection(book, !isUnselectingRange);
if (isUnselectingRange) {
this.selectedBooks.delete(book.id);
} else {
this.selectedBooks.add(book.id);
}
} }
} }
this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks); this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks);
} }
handleBookSelect(bookId: number, selected: boolean): void { handleBookSelect(book: Book, selected: boolean): void {
if (selected) { this.handleBookSelection(book, selected);
this.selectedBooks.add(bookId);
} else {
this.selectedBooks.delete(bookId);
}
this.isDrawerVisible = this.selectedBooks.size > 0; this.isDrawerVisible = this.selectedBooks.size > 0;
this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks); this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks);
} }
@@ -543,8 +550,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.selectedBooks.clear(); this.selectedBooks.clear();
}); });
}, },
reject: () => { reject: () => {}
}
}); });
} }
@@ -33,13 +33,13 @@ import {BookNavigationService} from '../../../service/book-navigation.service';
}) })
export class BookCardComponent implements OnInit, OnChanges, OnDestroy { export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
@Output() checkboxClick = new EventEmitter<{ index: number; bookId: number; selected: boolean; shiftKey: boolean }>(); @Output() checkboxClick = new EventEmitter<{ index: number; book: Book; selected: boolean; shiftKey: boolean }>();
@Output() menuToggled = new EventEmitter<boolean>(); @Output() menuToggled = new EventEmitter<boolean>();
@Input() index!: number; @Input() index!: number;
@Input() book!: Book; @Input() book!: Book;
@Input() isCheckboxEnabled: boolean = false; @Input() isCheckboxEnabled: boolean = false;
@Input() onBookSelect?: (bookId: number, selected: boolean) => void; @Input() onBookSelect?: (book: Book, selected: boolean) => void;
@Input() isSelected: boolean = false; @Input() isSelected: boolean = false;
@Input() bottomBarHidden: boolean = false; @Input() bottomBarHidden: boolean = false;
@Input() seriesViewEnabled: boolean = false; @Input() seriesViewEnabled: boolean = false;
@@ -694,13 +694,13 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
this.checkboxClick.emit({ this.checkboxClick.emit({
index: this.index, index: this.index,
bookId: this.book.id, book: this.book,
selected: selected, selected: selected,
shiftKey: shiftKey, shiftKey: shiftKey,
}); });
if (this.onBookSelect) { if (this.onBookSelect) {
this.onBookSelect(this.book.id, selected); this.onBookSelect(this.book, selected);
} }
this.lastMouseEvent = null; this.lastMouseEvent = null;
@@ -81,6 +81,7 @@ export class SeriesCollapseFilter implements BookFilter, OnDestroy {
const firstBook = sortedGroup[0]; const firstBook = sortedGroup[0];
collapsedBooks.push({ collapsedBooks.push({
...firstBook, ...firstBook,
seriesBooks: group,
seriesCount: group.length seriesCount: group.length
}); });
} }
@@ -40,6 +40,7 @@ export interface Book extends FileInfo {
koreaderProgress?: KoReaderProgress; koreaderProgress?: KoReaderProgress;
koboProgress?: KoboProgress; koboProgress?: KoboProgress;
seriesCount?: number | null; seriesCount?: number | null;
seriesBooks?: Book[] | null;
metadataMatchScore?: number | null; metadataMatchScore?: number | null;
personalRating?: number | null; personalRating?: number | null;
readStatus?: ReadStatus; readStatus?: ReadStatus;