From d21cb78baa2ea23525f3680cc8b6d8b52401a958 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 18 Sep 2020 21:47:15 +0200 Subject: [PATCH] fix wrong dateLastEdited timestamp, closes #1254 --- src/services/note_revisions.js | 10 ++++++++-- src/services/notes.js | 22 +--------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/services/note_revisions.js b/src/services/note_revisions.js index b9c70f96a..329bfd499 100644 --- a/src/services/note_revisions.js +++ b/src/services/note_revisions.js @@ -30,7 +30,13 @@ function createNoteRevision(note) { return; } - const contentMetadata = note.getContentMetadata(); + const content = note.getContent(); + + if (!content) { + return; + } + + const contentMetadata = note.getContentMetadata();console.log("contentMetadata", contentMetadata); const noteRevision = new NoteRevision({ noteId: note.noteId, @@ -50,7 +56,7 @@ function createNoteRevision(note) { dateCreated: dateUtils.localNowDateTime() }).save(); - noteRevision.setContent(note.getContent()); + noteRevision.setContent(content); return noteRevision; } diff --git a/src/services/notes.js b/src/services/notes.js index 14f0eefef..7da60e784 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -466,27 +466,7 @@ function saveNoteRevision(note) { const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.utcDateCreated).getTime(); if (!existingNoteRevisionId && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) { - const content = note.getContent(); - - if (!content) { - return; - } - - const noteRevision = new NoteRevision({ - noteId: note.noteId, - // title and text should be decrypted now - title: note.title, - type: note.type, - mime: note.mime, - isProtected: false, // will be fixed in the protectNoteRevisions() call - utcDateLastEdited: note.utcDateModified, - utcDateCreated: dateUtils.utcNowDateTime(), - utcDateModified: dateUtils.utcNowDateTime(), - dateLastEdited: note.dateModified, - dateCreated: dateUtils.localNowDateTime() - }).save(); - - noteRevision.setContent(content); + noteRevisionService.createNoteRevision(note); } }