From 5010175b846708a9223c68c0b0d6953832b1d684 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 10 Dec 2020 21:56:48 +0100 Subject: [PATCH] adding few missing isErased = 0 conditions --- src/entities/note.js | 4 ++-- src/routes/api/recent_changes.js | 3 ++- src/services/notes.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/entities/note.js b/src/entities/note.js index 873a997e1..40faa8df8 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -776,7 +776,7 @@ class Note extends Entity { * @returns {NoteRevision[]} */ getRevisions() { - return this.repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]); + return this.repository.getEntities("SELECT * FROM note_revisions WHERE isErased = 0 AND noteId = ?", [this.noteId]); } /** @@ -806,7 +806,7 @@ class Note extends Entity { * @returns {boolean} - true if note has children */ hasChildren() { - return (this.getChildNotes()).length > 0; + return this.getChildNotes().length > 0; } /** diff --git a/src/routes/api/recent_changes.js b/src/routes/api/recent_changes.js index 3f6b9c539..017263405 100644 --- a/src/routes/api/recent_changes.js +++ b/src/routes/api/recent_changes.js @@ -23,7 +23,8 @@ function getRecentChanges(req) { note_revisions.dateCreated AS date FROM note_revisions - JOIN notes USING(noteId)`); + JOIN notes USING(noteId) + WHERE note_revisions.isErased = 0`); for (const noteRevision of noteRevisions) { if (noteCacheService.isInAncestor(noteRevision.noteId, ancestorNoteId)) { diff --git a/src/services/notes.js b/src/services/notes.js index abe6db525..e9240353e 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -468,7 +468,7 @@ function saveNoteRevision(note) { const revisionCutoff = dateUtils.utcDateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); const existingNoteRevisionId = sql.getValue( - "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND utcDateCreated >= ?", [note.noteId, revisionCutoff]); + "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND isErased = 0 AND utcDateCreated >= ?", [note.noteId, revisionCutoff]); const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.utcDateCreated).getTime();