Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
renamed dates in code as well
zadam1c41d459f0f5
diff --git a/src/entities/api_token.js b/src/entities/api_token.jsindex 31a083af8e..5b2b1b2cb9 100644--- a/src/entities/api_token.js+++ b/src/entities/api_token.js@@ -9,22 +9,22 @@ const dateUtils = require('../services/date_utils');* @param {string} apiTokenId - primary key* @param {string} token* @param {boolean} isDeleted - true if API token is deleted- * @param {string} dateCreated+ * @param {string} utcDateCreated** @extends Entity*/class ApiToken extends Entity {static get entityName() { return "api_tokens"; }static get primaryKeyName() { return "apiTokenId"; }- static get hashedProperties() { return ["apiTokenId", "token", "dateCreated", "isDeleted"]; }+ static get hashedProperties() { return ["apiTokenId", "token", "utcDateCreated", "isDeleted"]; }beforeSaving() {if (!this.isDeleted) {this.isDeleted = false;}- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();diff --git a/src/entities/attribute.js b/src/entities/attribute.jsindex 85cf2c8a6b..b03b8479c0 100644--- a/src/entities/attribute.js+++ b/src/entities/attribute.js@@ -16,15 +16,15 @@ const sql = require('../services/sql');* @param {int} position* @param {boolean} isInheritable* @param {boolean} isDeleted- * @param {string} dateCreated- * @param {string} dateModified+ * @param {string} utcDateCreated+ * @param {string} utcDateModified** @extends Entity*/class Attribute extends Entity {static get entityName() { return "attributes"; }static get primaryKeyName() { return "attributeId"; }- static get hashedProperties() { return ["attributeId", "noteId", "type", "name", "value", "isInheritable", "isDeleted", "dateCreated"]; }+ static get hashedProperties() { return ["attributeId", "noteId", "type", "name", "value", "isInheritable", "isDeleted", "utcDateCreated"]; }constructor(row) {super(row);@@ -95,14 +95,14 @@ class Attribute extends Entity {this.isDeleted = false;}- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();if (this.isChanged) {- this.dateModified = dateUtils.nowDate();+ this.utcDateModified = dateUtils.nowDate();}}diff --git a/src/entities/branch.js b/src/entities/branch.jsindex 96770e6c55..c686182b1d 100644--- a/src/entities/branch.js+++ b/src/entities/branch.js@@ -16,8 +16,8 @@ const sql = require('../services/sql');* @param {string} prefix* @param {boolean} isExpanded* @param {boolean} isDeleted- * @param {string} dateModified- * @param {string} dateCreated+ * @param {string} utcDateModified+ * @param {string} utcDateCreated** @extends Entity*/@@ -49,14 +49,14 @@ class Branch extends Entity {this.isDeleted = false;}- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();if (this.isChanged) {- this.dateModified = dateUtils.nowDate();+ this.utcDateModified = dateUtils.nowDate();}}diff --git a/src/entities/link.js b/src/entities/link.jsindex 32271386e6..47b27355f8 100644--- a/src/entities/link.js+++ b/src/entities/link.js@@ -13,15 +13,15 @@ const dateUtils = require('../services/date_utils');* @param {string} targetNoteId* @param {string} type* @param {boolean} isDeleted- * @param {string} dateModified- * @param {string} dateCreated+ * @param {string} utcDateModified+ * @param {string} utcDateCreated** @extends Entity*/class Link extends Entity {static get entityName() { return "links"; }static get primaryKeyName() { return "linkId"; }- static get hashedProperties() { return ["linkId", "noteId", "targetNoteId", "type", "isDeleted", "dateCreated", "dateModified"]; }+ static get hashedProperties() { return ["linkId", "noteId", "targetNoteId", "type", "isDeleted", "utcDateCreated", "utcDateModified"]; }async getNote() {return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);@@ -36,14 +36,14 @@ class Link extends Entity {this.isDeleted = false;}- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();if (this.isChanged) {- this.dateModified = dateUtils.nowDate();+ this.utcDateModified = dateUtils.nowDate();}}}diff --git a/src/entities/note.js b/src/entities/note.jsindex 2855d63a4d..610127f914 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -25,8 +25,8 @@ const STRING_MIME_TYPES = ["application/x-javascript"];* @property {string} title - note title* @property {boolean} isProtected - true if note is protected* @property {boolean} isDeleted - true if note is deleted- * @property {string} dateCreated- * @property {string} dateModified+ * @property {string} utcDateCreated+ * @property {string} utcDateModified** @extends Entity*/@@ -660,14 +660,14 @@ class Note extends Entity {this.isDeleted = false;}- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();if (this.isChanged) {- this.dateModified = dateUtils.nowDate();+ this.utcDateModified = dateUtils.nowDate();}}diff --git a/src/entities/note_content.js b/src/entities/note_content.jsindex fd4a443657..8a2d026305 100644--- a/src/entities/note_content.js+++ b/src/entities/note_content.js@@ -13,8 +13,8 @@ const noteFulltextService = require('../services/note_fulltext');* @property {string} noteId - reference to owning note* @property {boolean} isProtected - true if note content is protected* @property {blob} content - note content - e.g. HTML text for text notes, file payload for files- * @property {string} dateCreated- * @property {string} dateModified+ * @property {string} utcDateCreated+ * @property {string} utcDateModified** @extends Entity*/@@ -66,14 +66,14 @@ class NoteContent extends Entity {}beforeSaving() {- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();if (this.isChanged) {- this.dateModified = dateUtils.nowDate();+ this.utcDateModified = dateUtils.nowDate();}}diff --git a/src/entities/note_revision.js b/src/entities/note_revision.jsindex fb2213d934..1904f05044 100644--- a/src/entities/note_revision.js+++ b/src/entities/note_revision.js@@ -14,15 +14,15 @@ const repository = require('../services/repository');* @param {string} title* @param {string} content* @param {string} isProtected- * @param {string} dateModifiedFrom- * @param {string} dateModifiedTo+ * @param {string} utcDateModifiedFrom+ * @param {string} utcDateModifiedTo** @extends Entity*/class NoteRevision extends Entity {static get entityName() { return "note_revisions"; }static get primaryKeyName() { return "noteRevisionId"; }- static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "content", "isProtected", "dateModifiedFrom", "dateModifiedTo"]; }+ static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "content", "isProtected", "utcDateModifiedFrom", "utcDateModifiedTo"]; }constructor(row) {super(row);diff --git a/src/entities/option.js b/src/entities/option.jsindex b029a1bb15..b79294405f 100644--- a/src/entities/option.js+++ b/src/entities/option.js@@ -9,8 +9,8 @@ const dateUtils = require('../services/date_utils');* @param {string} name* @param {string} value* @param {boolean} isSynced- * @param {string} dateModified- * @param {string} dateCreated+ * @param {string} utcDateModified+ * @param {string} utcDateCreated** @extends Entity*/@@ -29,7 +29,7 @@ class Option extends Entity {super.beforeSaving();if (this.isChanged) {- this.dateModified = dateUtils.nowDate();+ this.utcDateModified = dateUtils.nowDate();}}}diff --git a/src/entities/recent_note.js b/src/entities/recent_note.jsindex 32d8515be8..d011a85ba6 100644--- a/src/entities/recent_note.js+++ b/src/entities/recent_note.js@@ -9,22 +9,22 @@ const dateUtils = require('../services/date_utils');* @param {string} branchId* @param {string} notePath* @param {boolean} isDeleted- * @param {string} dateModified+ * @param {string} utcDateModified** @extends Entity*/class RecentNote extends Entity {static get entityName() { return "recent_notes"; }static get primaryKeyName() { return "branchId"; }- static get hashedProperties() { return ["branchId", "notePath", "dateCreated", "isDeleted"]; }+ static get hashedProperties() { return ["branchId", "notePath", "utcDateCreated", "isDeleted"]; }beforeSaving() {if (!this.isDeleted) {this.isDeleted = false;}- if (!this.dateCreated) {- this.dateCreated = dateUtils.nowDate();+ if (!this.utcDateCreated) {+ this.utcDateCreated = dateUtils.nowDate();}super.beforeSaving();diff --git a/src/public/javascripts/dialogs/event_log.js b/src/public/javascripts/dialogs/event_log.jsindex f8682abf9c..d964a2e84a 100644--- a/src/public/javascripts/dialogs/event_log.js+++ b/src/public/javascripts/dialogs/event_log.js@@ -15,7 +15,7 @@ async function showDialog() {$list.empty();for (const event of result) {- const dateTime = utils.formatDateTime(utils.parseDate(event.dateCreated));+ const dateTime = utils.formatDateTime(utils.parseDate(event.utcDateCreated));if (event.noteId) {const noteLink = await linkService.createNoteLink(event.noteId).prop('outerHTML');diff --git a/src/public/javascripts/dialogs/note_info.js b/src/public/javascripts/dialogs/note_info.jsindex 26d610a46c..98f1a4bc69 100644--- a/src/public/javascripts/dialogs/note_info.js+++ b/src/public/javascripts/dialogs/note_info.js@@ -2,8 +2,8 @@ import noteDetailService from '../services/note_detail.js';const $dialog = $("#note-info-dialog");const $noteId = $("#note-info-note-id");-const $dateCreated = $("#note-info-date-created");-const $dateModified = $("#note-info-date-modified");+const $utcDateCreated = $("#note-info-date-created");+const $utcDateModified = $("#note-info-date-modified");const $type = $("#note-info-type");const $mime = $("#note-info-mime");const $okButton = $("#note-info-ok-button");@@ -16,8 +16,8 @@ function showDialog() {const currentNote = noteDetailService.getCurrentNote();$noteId.text(currentNote.noteId);- $dateCreated.text(currentNote.dateCreated);- $dateModified.text(currentNote.dateModified);+ $utcDateCreated.text(currentNote.utcDateCreated);+ $utcDateModified.text(currentNote.utcDateModified);$type.text(currentNote.type);$mime.text(currentNote.mime);}diff --git a/src/public/javascripts/dialogs/note_revisions.js b/src/public/javascripts/dialogs/note_revisions.jsindex 9019119b63..df386ba9b4 100644--- a/src/public/javascripts/dialogs/note_revisions.js+++ b/src/public/javascripts/dialogs/note_revisions.js@@ -26,11 +26,11 @@ async function showNoteRevisionsDialog(noteId, noteRevisionId) {revisionItems = await server.get('notes/' + noteId + '/revisions');for (const item of revisionItems) {- const dateModified = utils.parseDate(item.dateModifiedFrom);+ const utcDateModified = utils.parseDate(item.utcDateModifiedFrom);$list.append($('<option>', {value: item.noteRevisionId,- text: utils.formatDateTime(dateModified)+ text: utils.formatDateTime(utcDateModified)}));}diff --git a/src/public/javascripts/dialogs/recent_changes.js b/src/public/javascripts/dialogs/recent_changes.jsindex 7e5d583672..68b0a38ca0 100644--- a/src/public/javascripts/dialogs/recent_changes.js+++ b/src/public/javascripts/dialogs/recent_changes.js@@ -26,7 +26,7 @@ async function showDialog() {const dayEl = $('<div>').append($('<b>').html(utils.formatDate(dateDay))).append(changesListEl);for (const change of dayChanges) {- const formattedTime = utils.formatTime(utils.parseDate(change.dateModifiedTo));+ const formattedTime = utils.formatTime(utils.parseDate(change.utcDateModifiedTo));let noteLink;@@ -51,7 +51,7 @@ function groupByDate(result) {const dayCache = {};for (const row of result) {- let dateDay = utils.parseDate(row.dateModifiedTo);+ let dateDay = utils.parseDate(row.utcDateModifiedTo);dateDay.setHours(0);dateDay.setMinutes(0);dateDay.setSeconds(0);diff --git a/src/public/javascripts/entities/attribute.js b/src/public/javascripts/entities/attribute.jsindex 1b388c4b52..18d0fdb271 100644--- a/src/public/javascripts/entities/attribute.js+++ b/src/public/javascripts/entities/attribute.js@@ -17,10 +17,10 @@ class Attribute {this.isInheritable = row.isInheritable;/** @param {boolean} isDeleted */this.isDeleted = row.isDeleted;- /** @param {string} dateCreated */- this.dateCreated = row.dateCreated;- /** @param {string} dateModified */- this.dateModified = row.dateModified;+ /** @param {string} utcDateCreated */+ this.utcDateCreated = row.utcDateCreated;+ /** @param {string} utcDateModified */+ this.utcDateModified = row.utcDateModified;}/** @returns {NoteShort} */diff --git a/src/public/javascripts/entities/note_full.js b/src/public/javascripts/entities/note_full.jsindex 44964669c3..f8ec6d0688 100644--- a/src/public/javascripts/entities/note_full.js+++ b/src/public/javascripts/entities/note_full.js@@ -11,10 +11,10 @@ class NoteFull extends NoteShort {this.noteContent = row.noteContent;/** @param {string} */- this.dateCreated = row.dateCreated;+ this.utcDateCreated = row.utcDateCreated;/** @param {string} */- this.dateModified = row.dateModified;+ this.utcDateModified = row.utcDateModified;}}diff --git a/src/routes/api/autocomplete.js b/src/routes/api/autocomplete.jsindex 4f83a5b70c..aec46a188e 100644--- a/src/routes/api/autocomplete.js+++ b/src/routes/api/autocomplete.js@@ -50,7 +50,7 @@ async function getRecentNotes(currentNoteId) {AND branches.noteId != ?${extraCondition}ORDER BY- dateCreated DESC+ utcDateCreated DESCLIMIT 200`, [currentNoteId]);return recentNotes.map(rn => {diff --git a/src/routes/api/branches.js b/src/routes/api/branches.jsindex cf0c91f3d7..9bd8fefcac 100644--- a/src/routes/api/branches.js+++ b/src/routes/api/branches.js@@ -48,7 +48,7 @@ async function moveBranchBeforeNote(req) {return [200, validationResult];}- // we don't change dateModified so other changes are prioritized in case of conflict+ // we don't change utcDateModified so other changes are prioritized in case of conflict// also we would have to sync all those modified branches otherwise hash checks would failawait sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0",[beforeNote.parentNoteId, beforeNote.notePosition]);@@ -76,7 +76,7 @@ async function moveBranchAfterNote(req) {return [200, validationResult];}- // we don't change dateModified so other changes are prioritized in case of conflict+ // we don't change utcDateModified so other changes are prioritized in case of conflict// also we would have to sync all those modified branches otherwise hash checks would failawait sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",[afterNote.parentNoteId, afterNote.notePosition]);diff --git a/src/routes/api/event_log.js b/src/routes/api/event_log.jsindex d5c7c3f21d..8503503404 100644--- a/src/routes/api/event_log.js+++ b/src/routes/api/event_log.js@@ -3,7 +3,7 @@const sql = require('../../services/sql');async function getEventLog() {- return await sql.getRows("SELECT * FROM event_log ORDER BY dateCreated DESC");+ return await sql.getRows("SELECT * FROM event_log ORDER BY utcDateCreated DESC");}module.exports = {diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.jsindex e35f509e7d..66b90267ab 100644--- a/src/routes/api/note_revisions.js+++ b/src/routes/api/note_revisions.js@@ -4,7 +4,7 @@ const repository = require('../../services/repository');async function getNoteRevisions(req) {const noteId = req.params.noteId;- return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ? order by dateModifiedTo desc", [noteId]);+ return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ? order by utcDateModifiedTo desc", [noteId]);}module.exports = {diff --git a/src/routes/api/recent_changes.js b/src/routes/api/recent_changes.jsindex 7c34efdefc..4a20753833 100644--- a/src/routes/api/recent_changes.js+++ b/src/routes/api/recent_changes.js@@ -14,7 +14,7 @@ async function getRecentChanges() {note_revisionsJOIN notes USING(noteId)ORDER BY- dateModifiedTo DESC+ utcDateModifiedTo DESCLIMIT 1000`);for (const change of recentChanges) {diff --git a/src/services/build_search_query.js b/src/services/build_search_query.jsindex eeaf0a1ae5..10585ce499 100644--- a/src/services/build_search_query.js+++ b/src/services/build_search_query.js@@ -1,7 +1,7 @@function isVirtualAttribute(filter) {return (- filter.name === "dateModified"- || filter.name === "dateCreated"+ filter.name === "utcDateModified"+ || filter.name === "utcDateCreated"|| filter.name === "isProtected");}diff --git a/src/services/cloning.js b/src/services/cloning.jsindex af987aceb6..64d5e06b1b 100644--- a/src/services/cloning.js+++ b/src/services/cloning.js@@ -79,7 +79,7 @@ async function cloneNoteAfter(noteId, afterBranchId) {return validationResult;}- // we don't change dateModified so other changes are prioritized in case of conflict+ // we don't change utcDateModified so other changes are prioritized in case of conflict// also we would have to sync all those modified branches otherwise hash checks would failawait sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",[afterNote.parentNoteId, afterNote.notePosition]);diff --git a/src/services/event_log.js b/src/services/event_log.jsindex 65cefed3b4..36208ce977 100644--- a/src/services/event_log.js+++ b/src/services/event_log.js@@ -12,7 +12,7 @@ async function addNoteEvent(noteId, comment) {eventId: utils.newEntityId(),noteId : noteId,comment: comment,- dateCreated: dateUtils.nowDate()+ utcDateCreated: dateUtils.nowDate()});log.info("Event log for " + noteId + ": " + comment);diff --git a/src/services/export/tar.js b/src/services/export/tar.jsindex 407bfe5fd3..f4ae65bc3b 100644--- a/src/services/export/tar.js+++ b/src/services/export/tar.js@@ -98,7 +98,7 @@ async function exportToTar(exportContext, branch, format, res) {isExpanded: branch.isExpanded,type: note.type,mime: note.mime,- // we don't export dateCreated and dateModified of any entity since that would be a bit misleading+ // we don't export utcDateCreated and utcDateModified of any entity since that would be a bit misleadingattributes: (await note.getOwnedAttributes()).map(attribute => {return {type: attribute.type,diff --git a/src/services/import/enex.js b/src/services/import/enex.jsindex 69ab19343e..be93aaa684 100644--- a/src/services/import/enex.js+++ b/src/services/import/enex.js@@ -165,9 +165,9 @@ async function importEnex(importContext, file, parentNote) {if (currentTag === 'title') {note.title = text;} else if (currentTag === 'created') {- note.dateCreated = parseDate(text);+ note.utcDateCreated = parseDate(text);} else if (currentTag === 'updated') {- // updated is currently ignored since dateModified is updated automatically with each save+ // updated is currently ignored since utcDateModified is updated automatically with each save} else if (currentTag === 'tag') {note.attributes.push({type: 'label',@@ -206,7 +206,7 @@ async function importEnex(importContext, file, parentNote) {async function saveNote() {// make a copy because stream continues with the next async call and note gets overwritten- let {title, content, attributes, resources, dateCreated} = note;+ let {title, content, attributes, resources, utcDateCreated} = note;const xmlObject = await parseXml(content);@@ -215,7 +215,7 @@ async function importEnex(importContext, file, parentNote) {const noteEntity = (await noteService.createNote(rootNote.noteId, title, content, {attributes,- dateCreated,+ utcDateCreated,type: 'text',mime: 'text/html',isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),diff --git a/src/services/notes.js b/src/services/notes.jsindex 7509956bf4..1db96e3ce4 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -27,7 +27,7 @@ async function getNewNotePosition(parentNoteId, noteData) {newNotePos = afterNote.notePosition + 1;- // not updating dateModified to avoig having to sync whole rows+ // not updating utcDateModified to avoig having to sync whole rowsawait sql.execute('UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0',[parentNoteId, afterNote.notePosition]);@@ -142,7 +142,7 @@ async function createNote(parentNoteId, title, content = "", extraOptions = {})isProtected: !!extraOptions.isProtected,type: extraOptions.type,mime: extraOptions.mime,- dateCreated: extraOptions.dateCreated,+ utcDateCreated: extraOptions.utcDateCreated,isExpanded: extraOptions.isExpanded,notePosition: extraOptions.notePosition};@@ -302,9 +302,9 @@ async function saveNoteRevision(note) {const revisionCutoff = dateUtils.dateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000));const existingNoteRevisionId = await sql.getValue(- "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND dateModifiedTo >= ?", [note.noteId, revisionCutoff]);+ "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND utcDateModifiedTo >= ?", [note.noteId, revisionCutoff]);- const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.dateCreated).getTime();+ const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.utcDateCreated).getTime();if (!existingNoteRevisionId && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) {await new NoteRevision({@@ -315,8 +315,8 @@ async function saveNoteRevision(note) {type: note.type,mime: note.mime,isProtected: false, // will be fixed in the protectNoteRevisions() call- dateModifiedFrom: note.dateModified,- dateModifiedTo: dateUtils.nowDate()+ utcDateModifiedFrom: note.utcDateModified,+ utcDateModifiedTo: dateUtils.nowDate()}).save();}}@@ -405,9 +405,9 @@ async function cleanupDeletedNotes() {// it's better to not use repository for this because it will complain about saving protected notes// out of protected session- await sql.execute("UPDATE note_contents SET content = NULL WHERE content IS NOT NULL AND noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1 AND notes.dateModified <= ?)", [dateUtils.dateStr(cutoffDate)]);+ await sql.execute("UPDATE note_contents SET content = NULL WHERE content IS NOT NULL AND noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1 AND notes.utcDateModified <= ?)", [dateUtils.dateStr(cutoffDate)]);- await sql.execute("UPDATE note_revisions SET content = NULL WHERE note_revisions.content IS NOT NULL AND noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1 AND notes.dateModified <= ?)", [dateUtils.dateStr(cutoffDate)]);+ await sql.execute("UPDATE note_revisions SET content = NULL WHERE note_revisions.content IS NOT NULL AND noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1 AND notes.utcDateModified <= ?)", [dateUtils.dateStr(cutoffDate)]);}sqlInit.dbReady.then(() => {diff --git a/src/services/source_id.js b/src/services/source_id.jsindex e0b027158a..6330298ab6 100644--- a/src/services/source_id.js+++ b/src/services/source_id.js@@ -8,7 +8,7 @@ const cls = require('./cls');async function saveSourceId(sourceId) {await sql.insert("source_ids", {sourceId: sourceId,- dateCreated: dateUtils.nowDate()+ utcDateCreated: dateUtils.nowDate()});await refreshSourceIds();@@ -30,7 +30,7 @@ async function generateSourceId() {}async function refreshSourceIds() {- allSourceIds = await sql.getColumn("SELECT sourceId FROM source_ids ORDER BY dateCreated DESC");+ allSourceIds = await sql.getColumn("SELECT sourceId FROM source_ids ORDER BY utcDateCreated DESC");}let allSourceIds = [];diff --git a/src/services/sync_table.js b/src/services/sync_table.jsindex df693606d9..af5aa62385 100644--- a/src/services/sync_table.js+++ b/src/services/sync_table.js@@ -48,7 +48,7 @@ async function addEntitySync(entityName, entityId, sourceId) {await sql.replace("sync", {entityName: entityName,entityId: entityId,- syncDate: dateUtils.nowDate(),+ utcSyncDate: dateUtils.nowDate(),sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId()});}@@ -78,7 +78,7 @@ async function fillSyncRows(entityName, entityKey, condition = '') {entityName: entityName,entityId: entityId,sourceId: "SYNC_FILL",- syncDate: dateUtils.nowDate()+ utcSyncDate: dateUtils.nowDate()});}}diff --git a/src/services/sync_update.js b/src/services/sync_update.jsindex 81b9a2465b..21538c9c3c 100644--- a/src/services/sync_update.js+++ b/src/services/sync_update.js@@ -55,7 +55,7 @@ async function updateEntity(sync, entity, sourceId) {async function updateNote(entity, sourceId) {const origNote = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [entity.noteId]);- if (!origNote || origNote.dateModified <= entity.dateModified) {+ if (!origNote || origNote.utcDateModified <= entity.utcDateModified) {await sql.transactional(async () => {await sql.replace("notes", entity);@@ -71,7 +71,7 @@ async function updateNote(entity, sourceId) {async function updateNoteContent(entity, sourceId) {const origNoteContent = await sql.getRow("SELECT * FROM note_contents WHERE noteId = ?", [entity.noteId]);- if (!origNoteContent || origNoteContent.dateModified <= entity.dateModified) {+ if (!origNoteContent || origNoteContent.utcDateModified <= entity.utcDateModified) {entity.content = entity.content === null ? null : Buffer.from(entity.content, 'base64');await sql.transactional(async () => {@@ -90,7 +90,7 @@ async function updateBranch(entity, sourceId) {const orig = await sql.getRowOrNull("SELECT * FROM branches WHERE branchId = ?", [entity.branchId]);await sql.transactional(async () => {- if (orig === null || orig.dateModified < entity.dateModified) {+ if (orig === null || orig.utcDateModified < entity.utcDateModified) {// isExpanded is not synced unless it's a new branch instance// otherwise in case of full new sync we'll get all branches (even root) collapsed.if (orig) {@@ -111,8 +111,8 @@ async function updateNoteRevision(entity, sourceId) {await sql.transactional(async () => {// we update note revision even if date modified to is the same because the only thing which might have changed- // is the protected status (and correnspondingly title and content) which doesn't affect the dateModifiedTo- if (orig === null || orig.dateModifiedTo <= entity.dateModifiedTo) {+ // is the protected status (and correnspondingly title and content) which doesn't affect the utcDateModifiedTo+ if (orig === null || orig.utcDateModifiedTo <= entity.utcDateModifiedTo) {entity.content = entity.content === null ? null : Buffer.from(entity.content, 'base64');await sql.replace('note_revisions', entity);@@ -142,7 +142,7 @@ async function updateOptions(entity, sourceId) {}await sql.transactional(async () => {- if (orig === null || orig.dateModified < entity.dateModified) {+ if (orig === null || orig.utcDateModified < entity.utcDateModified) {await sql.replace('options', entity);await syncTableService.addOptionsSync(entity.name, sourceId);@@ -155,7 +155,7 @@ async function updateOptions(entity, sourceId) {async function updateRecentNotes(entity, sourceId) {const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE branchId = ?", [entity.branchId]);- if (orig === null || orig.dateCreated < entity.dateCreated) {+ if (orig === null || orig.utcDateCreated < entity.utcDateCreated) {await sql.transactional(async () => {await sql.replace('recent_notes', entity);@@ -167,7 +167,7 @@ async function updateRecentNotes(entity, sourceId) {async function updateLink(entity, sourceId) {const origLink = await sql.getRow("SELECT * FROM links WHERE linkId = ?", [entity.linkId]);- if (!origLink || origLink.dateModified <= entity.dateModified) {+ if (!origLink || origLink.utcDateModified <= entity.utcDateModified) {await sql.transactional(async () => {await sql.replace("links", entity);@@ -181,7 +181,7 @@ async function updateLink(entity, sourceId) {async function updateAttribute(entity, sourceId) {const origAttribute = await sql.getRow("SELECT * FROM attributes WHERE attributeId = ?", [entity.attributeId]);- if (!origAttribute || origAttribute.dateModified <= entity.dateModified) {+ if (!origAttribute || origAttribute.utcDateModified <= entity.utcDateModified) {await sql.transactional(async () => {await sql.replace("attributes", entity);