mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	renamed dates in code as well
This commit is contained in:
		| @@ -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(); | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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'); | ||||
|   | ||||
| @@ -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); | ||||
| } | ||||
|   | ||||
| @@ -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) | ||||
|         })); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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} */ | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -50,7 +50,7 @@ async function getRecentNotes(currentNoteId) { | ||||
|         AND branches.noteId != ? | ||||
|         ${extraCondition} | ||||
|       ORDER BY  | ||||
|         dateCreated DESC | ||||
|         utcDateCreated DESC | ||||
|       LIMIT 200`, [currentNoteId]); | ||||
|  | ||||
|     return recentNotes.map(rn => { | ||||
|   | ||||
| @@ -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 fail | ||||
|     await 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 fail | ||||
|     await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0", | ||||
|         [afterNote.parentNoteId, afterNote.notePosition]); | ||||
|   | ||||
| @@ -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 = { | ||||
|   | ||||
| @@ -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 = { | ||||
|   | ||||
| @@ -14,7 +14,7 @@ async function getRecentChanges() { | ||||
|             note_revisions | ||||
|             JOIN notes USING(noteId) | ||||
|         ORDER BY  | ||||
|             dateModifiedTo DESC  | ||||
|             utcDateModifiedTo DESC  | ||||
|         LIMIT 1000`); | ||||
|  | ||||
|     for (const change of recentChanges) { | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| function isVirtualAttribute(filter) { | ||||
|     return ( | ||||
|         filter.name === "dateModified" | ||||
|         || filter.name === "dateCreated" | ||||
|         filter.name === "utcDateModified" | ||||
|         || filter.name === "utcDateCreated" | ||||
|         || filter.name === "isProtected" | ||||
|     ); | ||||
| } | ||||
|   | ||||
| @@ -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 fail | ||||
|     await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0", | ||||
|         [afterNote.parentNoteId, afterNote.notePosition]); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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 misleading | ||||
|             attributes: (await note.getOwnedAttributes()).map(attribute => { | ||||
|                 return { | ||||
|                     type: attribute.type, | ||||
|   | ||||
| @@ -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(), | ||||
|   | ||||
| @@ -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 rows | ||||
|         await 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(() => { | ||||
|   | ||||
| @@ -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 = []; | ||||
|   | ||||
| @@ -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() | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user