From 1a1a62d48efd0e1cd502170f04d5d3da53929f8d Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Thu, 14 Oct 2021 09:15:41 +0300 Subject: [PATCH] num analysis set now --- .../src/app/models/file/file-data.model.ts | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index 0f0f7fb53..0387b502b 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -105,34 +105,36 @@ export class FileDataModel { } private _isChangeLogEntry(redactionLogEntry: RedactionLogEntry, wrapper: RedactionLogEntryWrapper) { - redactionLogEntry.changes.sort((a, b) => moment(a.dateTime).valueOf() - moment(b.dateTime).valueOf()); + if (this.file.numberOfAnalyses > 0) { + redactionLogEntry.changes.sort((a, b) => moment(a.dateTime).valueOf() - moment(b.dateTime).valueOf()); - const lastChange = - redactionLogEntry.changes.length >= 1 ? redactionLogEntry.changes[redactionLogEntry.changes.length - 1] : undefined; - const page = redactionLogEntry.positions?.[0].page; + const lastChange = + redactionLogEntry.changes.length >= 1 ? redactionLogEntry.changes[redactionLogEntry.changes.length - 1] : undefined; + const page = redactionLogEntry.positions?.[0].page; - const viewedPage = this.viewedPages.pages.filter(p => p.page === page).pop(); + const viewedPage = this.viewedPages.pages.filter(p => p.page === page).pop(); - // page has been seen -> let's see if it's a change - if (viewedPage) { - const viewTime = moment(viewedPage.viewedTime); - // these are all unseen changes - const relevantChanges = redactionLogEntry.changes.filter(change => moment(change.dateTime).valueOf() > viewTime.valueOf()); - // at least one unseen change - if (relevantChanges.length > 0) { - wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type; - wrapper.isChangeLogEntry = true; - viewedPage.hasChanges = true; - this.hasChangeLog = true; + // page has been seen -> let's see if it's a change + if (viewedPage) { + const viewTime = moment(viewedPage.viewedTime).valueOf() - FileDataModel.DELTA_VIEW_TIME; + // these are all unseen changes + const relevantChanges = redactionLogEntry.changes.filter(change => moment(change.dateTime).valueOf() > viewTime); + // at least one unseen change + if (relevantChanges.length > 0) { + wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type; + wrapper.isChangeLogEntry = true; + viewedPage.hasChanges = true; + this.hasChangeLog = true; + } else { + // no relevant changes - hide removed anyway + wrapper.isChangeLogEntry = false; + wrapper.hidden = lastChange && lastChange.type === 'REMOVED'; + } } else { - // no relevant changes - hide removed anyway + // Page doesn't have a view-time wrapper.isChangeLogEntry = false; wrapper.hidden = lastChange && lastChange.type === 'REMOVED'; } - } else { - // Page doesn't have a view-time - wrapper.isChangeLogEntry = false; - wrapper.hidden = lastChange && lastChange.type === 'REMOVED'; } // console.log(wrapper.changeLogType, wrapper.hidden, wrapper.isChangeLogEntry, wrapper.value, lastChange); }