From 94789447182afe08984730572c05206b86014a2c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 2 Dec 2020 20:50:54 -0800 Subject: [PATCH] fix: Account for non-recorded views, closes #1700 --- app/models/Document.js | 2 +- app/scenes/Document/components/MarkAsViewed.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/Document.js b/app/models/Document.js index 0949d3925..4cc3278fe 100644 --- a/app/models/Document.js +++ b/app/models/Document.js @@ -207,7 +207,7 @@ export default class Document extends BaseModel { @action view = () => { // we don't record views for documents in the trash - if (this.isDeleted) { + if (this.isDeleted || !this.publishedAt) { return; } diff --git a/app/scenes/Document/components/MarkAsViewed.js b/app/scenes/Document/components/MarkAsViewed.js index 5c74f388e..ce1893be1 100644 --- a/app/scenes/Document/components/MarkAsViewed.js +++ b/app/scenes/Document/components/MarkAsViewed.js @@ -16,8 +16,9 @@ class MarkAsViewed extends React.Component { const { document } = this.props; this.viewTimeout = setTimeout(async () => { - if (document.publishedAt) { - const view = await document.view(); + const view = await document.view(); + + if (view) { document.updateLastViewed(view); } }, MARK_AS_VIEWED_AFTER);