fix: Account for non-recorded views, closes #1700

This commit is contained in:
Tom Moor
2020-12-02 20:50:54 -08:00
parent 9e1c5d1db3
commit 9478944718
2 changed files with 4 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -16,8 +16,9 @@ class MarkAsViewed extends React.Component<Props> {
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);