From de8052d752be1b6cea5bf74f676efaa90a1ec218 Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Tue, 30 May 2023 14:32:48 -0500 Subject: [PATCH] Fixed up jumpbar not properly disabling/enabling (#2022) --- .../card-detail-layout.component.ts | 29 +++++++++---------- openapi.json | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/UI/Web/src/app/cards/card-detail-layout/card-detail-layout.component.ts b/UI/Web/src/app/cards/card-detail-layout/card-detail-layout.component.ts index 4ab462f40..f8d2f2631 100644 --- a/UI/Web/src/app/cards/card-detail-layout/card-detail-layout.component.ts +++ b/UI/Web/src/app/cards/card-detail-layout/card-detail-layout.component.ts @@ -7,7 +7,7 @@ import { ContentChild, ElementRef, EventEmitter, - HostListener, + HostListener, inject, Inject, Input, OnChanges, @@ -76,7 +76,8 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { @ViewChild(VirtualScrollerComponent) private virtualScroller!: VirtualScrollerComponent; - filter!: SeriesFilter; + private readonly filterUtilityService = inject(FilterUtilitiesService); + filter: SeriesFilter = this.filterUtilityService.createSeriesFilter(); libraries: Array> = []; updateApplied: number = 0; @@ -86,12 +87,9 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { return Breakpoint; } - constructor(private filterUtilitySerivce: FilterUtilitiesService, public utilityService: UtilityService, - @Inject(DOCUMENT) private document: Document, private changeDetectionRef: ChangeDetectorRef, + constructor(public utilityService: UtilityService, + @Inject(DOCUMENT) private document: Document, private cdRef: ChangeDetectorRef, private jumpbarService: JumpbarService, private router: Router, private scrollService: ScrollService) { - this.filter = this.filterUtilitySerivce.createSeriesFilter(); - this.changeDetectionRef.markForCheck(); - } @HostListener('window:resize', ['$event']) @@ -99,7 +97,7 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { resizeJumpBar() { const currentSize = (this.document.querySelector('.viewport-container')?.getBoundingClientRect().height || 10) - 30; this.jumpBarKeysToRender = this.jumpbarService.generateJumpBar(this.jumpBarKeys, currentSize); - this.changeDetectionRef.markForCheck(); + this.cdRef.markForCheck(); } ngOnInit(): void { @@ -109,17 +107,17 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { if (this.filterSettings === undefined) { this.filterSettings = new FilterSettings(); - this.changeDetectionRef.markForCheck(); + this.cdRef.markForCheck(); } if (this.pagination === undefined) { this.pagination = {currentPage: 1, itemsPerPage: this.items.length, totalItems: this.items.length, totalPages: 1}; - this.changeDetectionRef.markForCheck(); + this.cdRef.markForCheck(); } if (this.refresh) { this.refresh.subscribe(() => { - this.changeDetectionRef.markForCheck(); + this.cdRef.markForCheck(); this.virtualScroller.refresh(); }); } @@ -152,7 +150,7 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { } hasCustomSort() { - return this.filter.sortOptions !== null || this.filterSettings?.presets?.sortOptions !== undefined; + return this.filter.sortOptions || this.filterSettings?.presets?.sortOptions; } performAction(action: ActionItem) { @@ -164,7 +162,8 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { applyMetadataFilter(event: FilterEvent) { this.applyFilter.emit(event); this.updateApplied++; - this.changeDetectionRef.markForCheck(); + this.filter = event.filter; + this.cdRef.markForCheck(); } @@ -172,7 +171,7 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { if (this.hasCustomSort()) return; let targetIndex = 0; - for(var i = 0; i < this.jumpBarKeys.length; i++) { + for(let i = 0; i < this.jumpBarKeys.length; i++) { if (this.jumpBarKeys[i].key === jumpKey.key) break; targetIndex += this.jumpBarKeys[i].size; } @@ -181,7 +180,7 @@ export class CardDetailLayoutComponent implements OnInit, OnChanges { this.jumpbarService.saveResumeKey(this.router.url, jumpKey.key); // TODO: This doesn't work, we need the offset from virtual scroller this.jumpbarService.saveScrollOffset(this.router.url, this.scrollService.scrollPosition); - this.changeDetectionRef.markForCheck(); + this.cdRef.markForCheck(); } tryToSaveJumpKey(item: any) { diff --git a/openapi.json b/openapi.json index 30a6a846f..36389003c 100644 --- a/openapi.json +++ b/openapi.json @@ -7,7 +7,7 @@ "name": "GPL-3.0", "url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE" }, - "version": "0.7.2.22" + "version": "0.7.2.24" }, "servers": [ {