RED-3800: fix highlights multiple load
This commit is contained in:
parent
1bd943fad8
commit
97a313d031
@ -361,21 +361,24 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
pairwise(),
|
||||
tap(annotations => this.deleteAnnotations(...annotations)),
|
||||
);
|
||||
const currentPageAnnotations$ = combineLatest([this.pdf.currentPage$, annotations$]).pipe(
|
||||
|
||||
const currentPageIfNotHighlightsView$ = combineLatest([this.pdf.currentPage$, this._viewModeService.viewMode$]).pipe(
|
||||
filter(([, viewMode]) => viewMode !== ViewModes.TEXT_HIGHLIGHTS),
|
||||
map(([page]) => page),
|
||||
);
|
||||
|
||||
const currentPageAnnotations$ = combineLatest([currentPageIfNotHighlightsView$, annotations$]).pipe(
|
||||
map(
|
||||
([page, [oldAnnotations, newAnnotations]]) =>
|
||||
[oldAnnotations.filter(byPage(page)), newAnnotations.filter(byPage(page))] as const,
|
||||
),
|
||||
);
|
||||
|
||||
let start;
|
||||
return combineLatest([currentPageAnnotations$, documentLoaded$]).pipe(
|
||||
filter(([, loaded]) => loaded),
|
||||
tap(() => (start = new Date().getTime())),
|
||||
map(([annotations]) => annotations),
|
||||
switchMap(annotations => this.drawChangedAnnotations(...annotations)),
|
||||
tap(([, newAnnotations]) => this.#highlightSelectedAnnotations(newAnnotations)),
|
||||
tap(() => this._logger.info(`[ANNOTATIONS] Processing time: ${new Date().getTime() - start}`)),
|
||||
tap(() => this.updateViewMode()),
|
||||
);
|
||||
}
|
||||
@ -423,7 +426,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
#rebuildFilters() {
|
||||
const startTime = new Date().getTime();
|
||||
|
||||
const annotationFilters = this._annotationProcessingService.getAnnotationFilter(this._fileDataService.all);
|
||||
const annotationFilters = this._annotationProcessingService.getAnnotationFilter();
|
||||
const primaryFilters = this._filterService.getGroup('primaryFilters')?.filters;
|
||||
this._filterService.addFilterGroup({
|
||||
slug: 'primaryFilters',
|
||||
@ -584,30 +587,28 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
if (!newAnnotations.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentFilters = this._filterService.getGroup('primaryFilters')?.filters || [];
|
||||
this.#rebuildFilters();
|
||||
|
||||
const startTime = new Date().getTime();
|
||||
|
||||
if (currentFilters) {
|
||||
this._handleDeltaAnnotationFilters(currentFilters, this._fileDataService.all);
|
||||
this._handleDeltaAnnotationFilters(currentFilters);
|
||||
}
|
||||
|
||||
await this._annotationDrawService.draw(newAnnotations, this.state.dossierTemplateId, this._skippedService.hideSkipped);
|
||||
this._logger.info(`[ANNOTATIONS] Redraw time: ${new Date().getTime() - startTime} ms for ${newAnnotations.length} annotations`);
|
||||
}
|
||||
|
||||
private _handleDeltaAnnotationFilters(currentFilters: NestedFilter[], newAnnotations: AnnotationWrapper[]) {
|
||||
private _handleDeltaAnnotationFilters(currentFilters: NestedFilter[]) {
|
||||
const primaryFilterGroup = this._filterService.getGroup('primaryFilters');
|
||||
const primaryFilters = primaryFilterGroup.filters;
|
||||
const secondaryFilters = this._filterService.getGroup('secondaryFilters').filters;
|
||||
const hasAnyFilterSet = [...primaryFilters, ...secondaryFilters].find(f => f.checked || f.indeterminate);
|
||||
const hasAnyFilterSet = [...primaryFilters, ...secondaryFilters].some(f => f.checked || f.indeterminate);
|
||||
|
||||
if (!hasAnyFilterSet) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newPageSpecificFilters = this._annotationProcessingService.getAnnotationFilter(newAnnotations);
|
||||
const newPageSpecificFilters = this._annotationProcessingService.getAnnotationFilter();
|
||||
|
||||
handleFilterDelta(currentFilters, newPageSpecificFilters, primaryFilters);
|
||||
this._filterService.addFilterGroup({
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { SuperTypeSorter } from '../../../utils';
|
||||
import { Filter, handleCheckedValue, IFilter, INestedFilter, NestedFilter } from '@iqser/common-ui';
|
||||
@ -7,10 +7,13 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { IViewedPage } from '@red/domain';
|
||||
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
|
||||
import { FilePreviewStateService } from './file-preview-state.service';
|
||||
import { FileDataService } from './file-data.service';
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationProcessingService {
|
||||
constructor(private readonly _state: FilePreviewStateService, private readonly _dictionariesMapService: DictionariesMapService) {}
|
||||
readonly #fileDataService = inject(FileDataService);
|
||||
readonly #state = inject(FilePreviewStateService);
|
||||
readonly #dictionariesMapService = inject(DictionariesMapService);
|
||||
|
||||
static secondaryAnnotationFilters(viewedPages?: IViewedPage[]): INestedFilter[] {
|
||||
const _viewedPages = viewedPages ? viewedPages.map(page => page.page) : [];
|
||||
@ -50,11 +53,11 @@ export class AnnotationProcessingService {
|
||||
].map(item => new NestedFilter(item));
|
||||
}
|
||||
|
||||
getAnnotationFilter(annotations: AnnotationWrapper[]): INestedFilter[] {
|
||||
getAnnotationFilter(): INestedFilter[] {
|
||||
const filterMap = new Map<string, INestedFilter>();
|
||||
const filters: INestedFilter[] = [];
|
||||
|
||||
annotations?.forEach(a => {
|
||||
this.#fileDataService.all?.forEach(a => {
|
||||
const topLevelFilter = a.topLevelFilter;
|
||||
const filter = filterMap.get(a.filterKey);
|
||||
if (filter) {
|
||||
@ -76,8 +79,8 @@ export class AnnotationProcessingService {
|
||||
}
|
||||
const dictionary =
|
||||
a.type === 'dossier_redaction'
|
||||
? this._state.dossierDictionary
|
||||
: this._dictionariesMapService.getDictionary(a.type, this._state.dossierTemplateId);
|
||||
? this.#state.dossierDictionary
|
||||
: this.#dictionariesMapService.getDictionary(a.type, this.#state.dossierTemplateId);
|
||||
const childFilter: IFilter = {
|
||||
id: a.filterKey,
|
||||
label: dictionary.label,
|
||||
@ -212,11 +215,13 @@ export class AnnotationProcessingService {
|
||||
if (first.pageNumber === second.pageNumber) {
|
||||
if (first.y > second.y) {
|
||||
return -1;
|
||||
} else if (first.y < second.y) {
|
||||
return 1;
|
||||
} else {
|
||||
return first.x < second.x ? -1 : 1;
|
||||
}
|
||||
|
||||
if (first.y < second.y) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return first.x < second.x ? -1 : 1;
|
||||
}
|
||||
return first.pageNumber < second.pageNumber ? -1 : 1;
|
||||
});
|
||||
|
||||
@ -73,13 +73,7 @@ export class REDDocumentViewer {
|
||||
get #textSelected$(): Observable<string> {
|
||||
return fromEvent<[Quad, string, number]>(this.#document, 'textSelected').pipe(
|
||||
tap(([, selectedText]) => (this.selectedText = selectedText)),
|
||||
tap(([, , pageNumber]) => {
|
||||
if (this._pdf.isCompare && pageNumber % 2 === 0) {
|
||||
this._pdf.disable('textPopup');
|
||||
} else {
|
||||
this._pdf.enable('textPopup');
|
||||
}
|
||||
}),
|
||||
tap(([, , pageNumber]) => this.#disableTextPopupIfCompareMode(pageNumber)),
|
||||
map(([, selectedText]) => selectedText),
|
||||
);
|
||||
}
|
||||
@ -164,9 +158,17 @@ export class REDDocumentViewer {
|
||||
}
|
||||
}
|
||||
|
||||
#disableTextPopupIfCompareMode(pageNumber) {
|
||||
if (this._pdf.isCompare && pageNumber % 2 === 0) {
|
||||
return this._pdf.disable('textPopup');
|
||||
}
|
||||
|
||||
this._pdf.enable('textPopup');
|
||||
}
|
||||
|
||||
#setCurrentPage() {
|
||||
const currentDocPage = this._activatedRoute.snapshot.queryParamMap.get('page');
|
||||
this.#document.setCurrentPage(Number(currentDocPage ?? '1'), false);
|
||||
this._pdf.navigateTo(currentDocPage ?? 1);
|
||||
}
|
||||
|
||||
#setInitialDisplayMode() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user