fix storing dateLastEdited timestamp in note revisions

This commit is contained in:
zadam 2020-09-06 22:04:11 +02:00
parent 032ffa8367
commit b0bf88c487
2 changed files with 9 additions and 2 deletions

View File

@ -105,6 +105,7 @@ class Note extends Entity {
} }
} }
/** @returns {{contentLength, dateModified, utcDateModified}} */
getContentMetadata() { getContentMetadata() {
return sql.getRow(` return sql.getRow(`
SELECT SELECT

View File

@ -30,6 +30,8 @@ function createNoteRevision(note) {
return; return;
} }
const contentMetadata = note.getContentMetadata();
const noteRevision = new NoteRevision({ const noteRevision = new NoteRevision({
noteId: note.noteId, noteId: note.noteId,
// title and text should be decrypted now // title and text should be decrypted now
@ -37,10 +39,14 @@ function createNoteRevision(note) {
type: note.type, type: note.type,
mime: note.mime, mime: note.mime,
isProtected: false, // will be fixed in the protectNoteRevisions() call isProtected: false, // will be fixed in the protectNoteRevisions() call
utcDateLastEdited: note.utcDateModified, utcDateLastEdited: note.utcDateModified > contentMetadata.utcDateModified
? note.utcDateModified
: contentMetadata.utcDateModified,
utcDateCreated: dateUtils.utcNowDateTime(), utcDateCreated: dateUtils.utcNowDateTime(),
utcDateModified: dateUtils.utcNowDateTime(), utcDateModified: dateUtils.utcNowDateTime(),
dateLastEdited: note.dateModified, dateLastEdited: note.dateModified > contentMetadata.dateModified
? note.dateModified
: contentMetadata.dateModified,
dateCreated: dateUtils.localNowDateTime() dateCreated: dateUtils.localNowDateTime()
}).save(); }).save();