fix(collapse-series): fix series collapsing (#541)

This commit is contained in:
brios
2026-04-22 17:27:38 -04:00
committed by Zach Yale
parent f292a3e683
commit e26df36a33
8 changed files with 24 additions and 10 deletions
@@ -439,6 +439,17 @@ describe('BookBrowserComponent', () => {
expect(component.showTableLoadingPlaceholder()).toBe(false);
});
it('calls SeriesCollapseFilter.collapseBooks when computing pipelineInputs', () => {
createHarness();
const filter = TestBed.inject(SeriesCollapseFilter);
const collapseBooksSpy = vi.spyOn(filter, 'collapseBooks');
vi.runOnlyPendingTimers();
TestBed.flushEffects();
expect(collapseBooksSpy).toHaveBeenCalled();
});
it('triggers next page fetch when scrolled near the bottom of rendered content', async () => {
const {component} = createHarness();
const appBooksApi = TestBed.inject(AppBooksApiService);
@@ -264,7 +264,10 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
return Number.isNaN(entityId) ? entityType : `${entityType}:${entityId}`;
});
private readonly pipelineInputs = computed(() => this.appBooksApi.books());
private readonly pipelineInputs = computed(() => {
const books = this.appBooksApi.books();
return this.seriesCollapseFilter.collapseBooks(books, this.forceExpandSeries());
});
private readonly renderBooksEffect = effect((onCleanup) => {
const contextKey = this.booksContextKey();
@@ -149,7 +149,7 @@
{{ t('emptyState') }}
</div>
} @else {
@for (file of bookdropFileUis; track file) {
@for (file of bookdropFileUis; track file.file.id) {
<div class="file-item">
<div class="file-row" [ngClass]="file.showDetails ? ' expanded' : ''">
@@ -41,7 +41,7 @@
<div class="results-list">
<ul class="file-list">
@for (r of result.results; track r) {
@for (r of result.results; track r.fileName + ':' + $index) {
<li
class="file-item"
[ngClass]="{
@@ -38,7 +38,7 @@
<div class="tab-content">
@if (bookInSeries.length > 1) {
<div class="dashboard-scroller-infinite" infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" [horizontal]="true">
@for (bookInSeriesItem of bookInSeries; track bookInSeriesItem) {
@for (bookInSeriesItem of bookInSeries; track bookInSeriesItem.id) {
@if (bookInSeriesItem.id !== book.id) {
<div class="dashboard-scroller-card">
<app-book-card-lite-component [book]="bookInSeriesItem" [showSeriesNumber]="true" [isActive]="bookInSeriesItem.id === book.id"></app-book-card-lite-component>
@@ -40,7 +40,7 @@
@if (showBookList) {
<div class="book-list-panel">
<ul class="book-list">
@for (book of books; track book) {
@for (book of books; track book.id) {
<li>{{ book.metadata?.title || 'Untitled Book' }}</li>
}
</ul>