diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html index 47d3dc13b..d202d612c 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html @@ -146,7 +146,7 @@ id="annotations-list" tabindex="1" > - + (); - readonly activeAnnotations = computed(() => this.displayedAnnotations.get(this.pdf.currentPage()) || []); + protected displayedAnnotations = signal(new Map()); + readonly activeAnnotations = computed(() => this.displayedAnnotations().get(this.pdf.currentPage()) || []); protected displayedPages: number[] = []; protected pagesPanelActive = true; protected enabledFilters = []; @@ -362,11 +363,11 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On if ($event.key === 'ArrowDown') { const nextPage = this.#nextPageWithAnnotations(); - return this.listingService.selectAnnotations(this.displayedAnnotations.get(nextPage)[0]); + return this.listingService.selectAnnotations(this.displayedAnnotations().get(nextPage)[0]); } const prevPage = this.#prevPageWithAnnotations(); - const prevPageAnnotations = this.displayedAnnotations.get(prevPage); + const prevPageAnnotations = this.displayedAnnotations().get(prevPage); return this.listingService.selectAnnotations(getLast(prevPageAnnotations)); } @@ -375,7 +376,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On const pageIdx = this.displayedPages.indexOf(page); const nextPageIdx = pageIdx + 1; const previousPageIdx = pageIdx - 1; - const annotationsOnPage = this.displayedAnnotations.get(page); + const annotationsOnPage = this.displayedAnnotations().get(page); const idx = annotationsOnPage.findIndex(a => a.id === this._firstSelectedAnnotation.id); if ($event.key === 'ArrowDown') { @@ -385,7 +386,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } else if (nextPageIdx < this.displayedPages.length) { // If not last page for (let i = nextPageIdx; i < this.displayedPages.length; i++) { - const nextPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]); + const nextPageAnnotations = this.displayedAnnotations().get(this.displayedPages[i]); if (nextPageAnnotations) { this.listingService.selectAnnotations(nextPageAnnotations[0]); break; @@ -403,7 +404,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On if (pageIdx) { // If not first page for (let i = previousPageIdx; i >= 0; i--) { - const prevPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]); + const prevPageAnnotations = this.displayedAnnotations().get(this.displayedPages[i]); if (prevPageAnnotations) { this.listingService.selectAnnotations(getLast(prevPageAnnotations)); break; @@ -451,8 +452,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } } - this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary); - const pagesThatDisplayAnnotations = [...this.displayedAnnotations.keys()]; + this.displayedAnnotations.set(this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary)); + const pagesThatDisplayAnnotations = [...this.displayedAnnotations().keys()]; this.enabledFilters = this.filterService.enabledFlatFilters; if (this.enabledFilters.some(f => f.id === 'pages-without-annotations')) { if (this.enabledFilters.length === 1 && !onlyPageWithAnnotations) { @@ -461,7 +462,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } else { this.#setDisplayedPages([]); } - this.displayedAnnotations.clear(); + this.displayedAnnotations().clear(); } else if (this.enabledFilters.length || onlyPageWithAnnotations || componentReferenceIds) { this.#setDisplayedPages(pagesThatDisplayAnnotations); } else { @@ -469,7 +470,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } this.displayedPages.sort((a, b) => a - b); - return this.displayedAnnotations; + return this.displayedAnnotations(); } #selectFirstAnnotationOnCurrentPageIfNecessary() { @@ -521,7 +522,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On const currentPage = untracked(this.pdf.currentPage); let idx = 0; for (const page of this.displayedPages) { - if (page > currentPage && this.displayedAnnotations.get(page)) { + if (page > currentPage && this.displayedAnnotations().get(page)) { break; } ++idx; @@ -534,7 +535,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On let idx = this.displayedPages.length - 1; const reverseDisplayedPages = [...this.displayedPages].reverse(); for (const page of reverseDisplayedPages) { - if (page < currentPage && this.displayedAnnotations.get(page)) { + if (page < currentPage && this.displayedAnnotations().get(page)) { break; } --idx;