mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +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} apiTokenId - primary key | ||||||
|  * @param {string} token |  * @param {string} token | ||||||
|  * @param {boolean} isDeleted - true if API token is deleted |  * @param {boolean} isDeleted - true if API token is deleted | ||||||
|  * @param {string} dateCreated |  * @param {string} utcDateCreated | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| class ApiToken extends Entity { | class ApiToken extends Entity { | ||||||
|     static get entityName() { return "api_tokens"; } |     static get entityName() { return "api_tokens"; } | ||||||
|     static get primaryKeyName() { return "apiTokenId"; } |     static get primaryKeyName() { return "apiTokenId"; } | ||||||
|     static get hashedProperties() { return ["apiTokenId", "token", "dateCreated", "isDeleted"]; } |     static get hashedProperties() { return ["apiTokenId", "token", "utcDateCreated", "isDeleted"]; } | ||||||
|  |  | ||||||
|     beforeSaving() { |     beforeSaving() { | ||||||
|         if (!this.isDeleted) { |         if (!this.isDeleted) { | ||||||
|             this.isDeleted = false; |             this.isDeleted = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|   | |||||||
| @@ -16,15 +16,15 @@ const sql = require('../services/sql'); | |||||||
|  * @param {int} position |  * @param {int} position | ||||||
|  * @param {boolean} isInheritable |  * @param {boolean} isInheritable | ||||||
|  * @param {boolean} isDeleted |  * @param {boolean} isDeleted | ||||||
|  * @param {string} dateCreated |  * @param {string} utcDateCreated | ||||||
|  * @param {string} dateModified |  * @param {string} utcDateModified | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| class Attribute extends Entity { | class Attribute extends Entity { | ||||||
|     static get entityName() { return "attributes"; } |     static get entityName() { return "attributes"; } | ||||||
|     static get primaryKeyName() { return "attributeId"; } |     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) { |     constructor(row) { | ||||||
|         super(row); |         super(row); | ||||||
| @@ -95,14 +95,14 @@ class Attribute extends Entity { | |||||||
|             this.isDeleted = false; |             this.isDeleted = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|  |  | ||||||
|         if (this.isChanged) { |         if (this.isChanged) { | ||||||
|             this.dateModified = dateUtils.nowDate(); |             this.utcDateModified = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,8 +16,8 @@ const sql = require('../services/sql'); | |||||||
|  * @param {string} prefix |  * @param {string} prefix | ||||||
|  * @param {boolean} isExpanded |  * @param {boolean} isExpanded | ||||||
|  * @param {boolean} isDeleted |  * @param {boolean} isDeleted | ||||||
|  * @param {string} dateModified |  * @param {string} utcDateModified | ||||||
|  * @param {string} dateCreated |  * @param {string} utcDateCreated | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| @@ -49,14 +49,14 @@ class Branch extends Entity { | |||||||
|             this.isDeleted = false; |             this.isDeleted = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|  |  | ||||||
|         if (this.isChanged) { |         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} targetNoteId | ||||||
|  * @param {string} type |  * @param {string} type | ||||||
|  * @param {boolean} isDeleted |  * @param {boolean} isDeleted | ||||||
|  * @param {string} dateModified |  * @param {string} utcDateModified | ||||||
|  * @param {string} dateCreated |  * @param {string} utcDateCreated | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| class Link extends Entity { | class Link extends Entity { | ||||||
|     static get entityName() { return "links"; } |     static get entityName() { return "links"; } | ||||||
|     static get primaryKeyName() { return "linkId"; } |     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() { |     async getNote() { | ||||||
|         return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); |         return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); | ||||||
| @@ -36,14 +36,14 @@ class Link extends Entity { | |||||||
|             this.isDeleted = false; |             this.isDeleted = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|  |  | ||||||
|         if (this.isChanged) { |         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 {string} title - note title | ||||||
|  * @property {boolean} isProtected - true if note is protected |  * @property {boolean} isProtected - true if note is protected | ||||||
|  * @property {boolean} isDeleted - true if note is deleted |  * @property {boolean} isDeleted - true if note is deleted | ||||||
|  * @property {string} dateCreated |  * @property {string} utcDateCreated | ||||||
|  * @property {string} dateModified |  * @property {string} utcDateModified | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| @@ -660,14 +660,14 @@ class Note extends Entity { | |||||||
|             this.isDeleted = false; |             this.isDeleted = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|  |  | ||||||
|         if (this.isChanged) { |         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 {string} noteId - reference to owning note | ||||||
|  * @property {boolean} isProtected - true if note content is protected |  * @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 {blob} content - note content - e.g. HTML text for text notes, file payload for files | ||||||
|  * @property {string} dateCreated |  * @property {string} utcDateCreated | ||||||
|  * @property {string} dateModified |  * @property {string} utcDateModified | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| @@ -66,14 +66,14 @@ class NoteContent extends Entity { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     beforeSaving() { |     beforeSaving() { | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|  |  | ||||||
|         if (this.isChanged) { |         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} title | ||||||
|  * @param {string} content |  * @param {string} content | ||||||
|  * @param {string} isProtected |  * @param {string} isProtected | ||||||
|  * @param {string} dateModifiedFrom |  * @param {string} utcDateModifiedFrom | ||||||
|  * @param {string} dateModifiedTo |  * @param {string} utcDateModifiedTo | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| class NoteRevision extends Entity { | class NoteRevision extends Entity { | ||||||
|     static get entityName() { return "note_revisions"; } |     static get entityName() { return "note_revisions"; } | ||||||
|     static get primaryKeyName() { return "noteRevisionId"; } |     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) { |     constructor(row) { | ||||||
|         super(row); |         super(row); | ||||||
|   | |||||||
| @@ -9,8 +9,8 @@ const dateUtils = require('../services/date_utils'); | |||||||
|  * @param {string} name |  * @param {string} name | ||||||
|  * @param {string} value |  * @param {string} value | ||||||
|  * @param {boolean} isSynced |  * @param {boolean} isSynced | ||||||
|  * @param {string} dateModified |  * @param {string} utcDateModified | ||||||
|  * @param {string} dateCreated |  * @param {string} utcDateCreated | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| @@ -29,7 +29,7 @@ class Option extends Entity { | |||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|  |  | ||||||
|         if (this.isChanged) { |         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} branchId | ||||||
|  * @param {string} notePath |  * @param {string} notePath | ||||||
|  * @param {boolean} isDeleted |  * @param {boolean} isDeleted | ||||||
|  * @param {string} dateModified |  * @param {string} utcDateModified | ||||||
|  * |  * | ||||||
|  * @extends Entity |  * @extends Entity | ||||||
|  */ |  */ | ||||||
| class RecentNote extends Entity { | class RecentNote extends Entity { | ||||||
|     static get entityName() { return "recent_notes"; } |     static get entityName() { return "recent_notes"; } | ||||||
|     static get primaryKeyName() { return "branchId"; } |     static get primaryKeyName() { return "branchId"; } | ||||||
|     static get hashedProperties() { return ["branchId", "notePath", "dateCreated", "isDeleted"]; } |     static get hashedProperties() { return ["branchId", "notePath", "utcDateCreated", "isDeleted"]; } | ||||||
|  |  | ||||||
|     beforeSaving() { |     beforeSaving() { | ||||||
|         if (!this.isDeleted) { |         if (!this.isDeleted) { | ||||||
|             this.isDeleted = false; |             this.isDeleted = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!this.dateCreated) { |         if (!this.utcDateCreated) { | ||||||
|             this.dateCreated = dateUtils.nowDate(); |             this.utcDateCreated = dateUtils.nowDate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         super.beforeSaving(); |         super.beforeSaving(); | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ async function showDialog() { | |||||||
|     $list.empty(); |     $list.empty(); | ||||||
|  |  | ||||||
|     for (const event of result) { |     for (const event of result) { | ||||||
|         const dateTime = utils.formatDateTime(utils.parseDate(event.dateCreated)); |         const dateTime = utils.formatDateTime(utils.parseDate(event.utcDateCreated)); | ||||||
|  |  | ||||||
|         if (event.noteId) { |         if (event.noteId) { | ||||||
|             const noteLink = await linkService.createNoteLink(event.noteId).prop('outerHTML'); |             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 $dialog = $("#note-info-dialog"); | ||||||
| const $noteId = $("#note-info-note-id"); | const $noteId = $("#note-info-note-id"); | ||||||
| const $dateCreated = $("#note-info-date-created"); | const $utcDateCreated = $("#note-info-date-created"); | ||||||
| const $dateModified = $("#note-info-date-modified"); | const $utcDateModified = $("#note-info-date-modified"); | ||||||
| const $type = $("#note-info-type"); | const $type = $("#note-info-type"); | ||||||
| const $mime = $("#note-info-mime"); | const $mime = $("#note-info-mime"); | ||||||
| const $okButton = $("#note-info-ok-button"); | const $okButton = $("#note-info-ok-button"); | ||||||
| @@ -16,8 +16,8 @@ function showDialog() { | |||||||
|     const currentNote = noteDetailService.getCurrentNote(); |     const currentNote = noteDetailService.getCurrentNote(); | ||||||
|  |  | ||||||
|     $noteId.text(currentNote.noteId); |     $noteId.text(currentNote.noteId); | ||||||
|     $dateCreated.text(currentNote.dateCreated); |     $utcDateCreated.text(currentNote.utcDateCreated); | ||||||
|     $dateModified.text(currentNote.dateModified); |     $utcDateModified.text(currentNote.utcDateModified); | ||||||
|     $type.text(currentNote.type); |     $type.text(currentNote.type); | ||||||
|     $mime.text(currentNote.mime); |     $mime.text(currentNote.mime); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,11 +26,11 @@ async function showNoteRevisionsDialog(noteId, noteRevisionId) { | |||||||
|     revisionItems = await server.get('notes/' + noteId + '/revisions'); |     revisionItems = await server.get('notes/' + noteId + '/revisions'); | ||||||
|  |  | ||||||
|     for (const item of revisionItems) { |     for (const item of revisionItems) { | ||||||
|         const dateModified = utils.parseDate(item.dateModifiedFrom); |         const utcDateModified = utils.parseDate(item.utcDateModifiedFrom); | ||||||
|  |  | ||||||
|         $list.append($('<option>', { |         $list.append($('<option>', { | ||||||
|             value: item.noteRevisionId, |             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); |         const dayEl = $('<div>').append($('<b>').html(utils.formatDate(dateDay))).append(changesListEl); | ||||||
|  |  | ||||||
|         for (const change of dayChanges) { |         for (const change of dayChanges) { | ||||||
|             const formattedTime = utils.formatTime(utils.parseDate(change.dateModifiedTo)); |             const formattedTime = utils.formatTime(utils.parseDate(change.utcDateModifiedTo)); | ||||||
|  |  | ||||||
|             let noteLink; |             let noteLink; | ||||||
|  |  | ||||||
| @@ -51,7 +51,7 @@ function groupByDate(result) { | |||||||
|     const dayCache = {}; |     const dayCache = {}; | ||||||
|  |  | ||||||
|     for (const row of result) { |     for (const row of result) { | ||||||
|         let dateDay = utils.parseDate(row.dateModifiedTo); |         let dateDay = utils.parseDate(row.utcDateModifiedTo); | ||||||
|         dateDay.setHours(0); |         dateDay.setHours(0); | ||||||
|         dateDay.setMinutes(0); |         dateDay.setMinutes(0); | ||||||
|         dateDay.setSeconds(0); |         dateDay.setSeconds(0); | ||||||
|   | |||||||
| @@ -17,10 +17,10 @@ class Attribute { | |||||||
|         this.isInheritable = row.isInheritable; |         this.isInheritable = row.isInheritable; | ||||||
|         /** @param {boolean} isDeleted */ |         /** @param {boolean} isDeleted */ | ||||||
|         this.isDeleted = row.isDeleted; |         this.isDeleted = row.isDeleted; | ||||||
|         /** @param {string} dateCreated */ |         /** @param {string} utcDateCreated */ | ||||||
|         this.dateCreated = row.dateCreated; |         this.utcDateCreated = row.utcDateCreated; | ||||||
|         /** @param {string} dateModified */ |         /** @param {string} utcDateModified */ | ||||||
|         this.dateModified = row.dateModified; |         this.utcDateModified = row.utcDateModified; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** @returns {NoteShort} */ |     /** @returns {NoteShort} */ | ||||||
|   | |||||||
| @@ -11,10 +11,10 @@ class NoteFull extends NoteShort { | |||||||
|         this.noteContent = row.noteContent; |         this.noteContent = row.noteContent; | ||||||
|  |  | ||||||
|         /** @param {string} */ |         /** @param {string} */ | ||||||
|         this.dateCreated = row.dateCreated; |         this.utcDateCreated = row.utcDateCreated; | ||||||
|  |  | ||||||
|         /** @param {string} */ |         /** @param {string} */ | ||||||
|         this.dateModified = row.dateModified; |         this.utcDateModified = row.utcDateModified; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -50,7 +50,7 @@ async function getRecentNotes(currentNoteId) { | |||||||
|         AND branches.noteId != ? |         AND branches.noteId != ? | ||||||
|         ${extraCondition} |         ${extraCondition} | ||||||
|       ORDER BY  |       ORDER BY  | ||||||
|         dateCreated DESC |         utcDateCreated DESC | ||||||
|       LIMIT 200`, [currentNoteId]); |       LIMIT 200`, [currentNoteId]); | ||||||
|  |  | ||||||
|     return recentNotes.map(rn => { |     return recentNotes.map(rn => { | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ async function moveBranchBeforeNote(req) { | |||||||
|         return [200, validationResult]; |         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 |     // 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", |     await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0", | ||||||
|         [beforeNote.parentNoteId, beforeNote.notePosition]); |         [beforeNote.parentNoteId, beforeNote.notePosition]); | ||||||
| @@ -76,7 +76,7 @@ async function moveBranchAfterNote(req) { | |||||||
|         return [200, validationResult]; |         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 |     // 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", |     await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0", | ||||||
|         [afterNote.parentNoteId, afterNote.notePosition]); |         [afterNote.parentNoteId, afterNote.notePosition]); | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
| const sql = require('../../services/sql'); | const sql = require('../../services/sql'); | ||||||
|  |  | ||||||
| async function getEventLog() { | 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 = { | module.exports = { | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ const repository = require('../../services/repository'); | |||||||
|  |  | ||||||
| async function getNoteRevisions(req) { | async function getNoteRevisions(req) { | ||||||
|     const noteId = req.params.noteId; |     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 = { | module.exports = { | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ async function getRecentChanges() { | |||||||
|             note_revisions |             note_revisions | ||||||
|             JOIN notes USING(noteId) |             JOIN notes USING(noteId) | ||||||
|         ORDER BY  |         ORDER BY  | ||||||
|             dateModifiedTo DESC  |             utcDateModifiedTo DESC  | ||||||
|         LIMIT 1000`); |         LIMIT 1000`); | ||||||
|  |  | ||||||
|     for (const change of recentChanges) { |     for (const change of recentChanges) { | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| function isVirtualAttribute(filter) { | function isVirtualAttribute(filter) { | ||||||
|     return ( |     return ( | ||||||
|         filter.name === "dateModified" |         filter.name === "utcDateModified" | ||||||
|         || filter.name === "dateCreated" |         || filter.name === "utcDateCreated" | ||||||
|         || filter.name === "isProtected" |         || filter.name === "isProtected" | ||||||
|     ); |     ); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -79,7 +79,7 @@ async function cloneNoteAfter(noteId, afterBranchId) { | |||||||
|         return validationResult; |         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 |     // 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", |     await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0", | ||||||
|         [afterNote.parentNoteId, afterNote.notePosition]); |         [afterNote.parentNoteId, afterNote.notePosition]); | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ async function addNoteEvent(noteId, comment) { | |||||||
|         eventId: utils.newEntityId(), |         eventId: utils.newEntityId(), | ||||||
|         noteId : noteId, |         noteId : noteId, | ||||||
|         comment: comment, |         comment: comment, | ||||||
|         dateCreated: dateUtils.nowDate() |         utcDateCreated: dateUtils.nowDate() | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     log.info("Event log for " + noteId + ": " + comment); |     log.info("Event log for " + noteId + ": " + comment); | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ async function exportToTar(exportContext, branch, format, res) { | |||||||
|             isExpanded: branch.isExpanded, |             isExpanded: branch.isExpanded, | ||||||
|             type: note.type, |             type: note.type, | ||||||
|             mime: note.mime, |             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 => { |             attributes: (await note.getOwnedAttributes()).map(attribute => { | ||||||
|                 return { |                 return { | ||||||
|                     type: attribute.type, |                     type: attribute.type, | ||||||
|   | |||||||
| @@ -165,9 +165,9 @@ async function importEnex(importContext, file, parentNote) { | |||||||
|             if (currentTag === 'title') { |             if (currentTag === 'title') { | ||||||
|                 note.title = text; |                 note.title = text; | ||||||
|             } else if (currentTag === 'created') { |             } else if (currentTag === 'created') { | ||||||
|                 note.dateCreated = parseDate(text); |                 note.utcDateCreated = parseDate(text); | ||||||
|             } else if (currentTag === 'updated') { |             } 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') { |             } else if (currentTag === 'tag') { | ||||||
|                 note.attributes.push({ |                 note.attributes.push({ | ||||||
|                     type: 'label', |                     type: 'label', | ||||||
| @@ -206,7 +206,7 @@ async function importEnex(importContext, file, parentNote) { | |||||||
|  |  | ||||||
|     async function saveNote() { |     async function saveNote() { | ||||||
|         // make a copy because stream continues with the next async call and note gets overwritten |         // 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); |         const xmlObject = await parseXml(content); | ||||||
|  |  | ||||||
| @@ -215,7 +215,7 @@ async function importEnex(importContext, file, parentNote) { | |||||||
|  |  | ||||||
|         const noteEntity = (await noteService.createNote(rootNote.noteId, title, content, { |         const noteEntity = (await noteService.createNote(rootNote.noteId, title, content, { | ||||||
|             attributes, |             attributes, | ||||||
|             dateCreated, |             utcDateCreated, | ||||||
|             type: 'text', |             type: 'text', | ||||||
|             mime: 'text/html', |             mime: 'text/html', | ||||||
|             isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), |             isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ async function getNewNotePosition(parentNoteId, noteData) { | |||||||
|  |  | ||||||
|         newNotePos = afterNote.notePosition + 1; |         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', |         await sql.execute('UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0', | ||||||
|             [parentNoteId, afterNote.notePosition]); |             [parentNoteId, afterNote.notePosition]); | ||||||
|  |  | ||||||
| @@ -142,7 +142,7 @@ async function createNote(parentNoteId, title, content = "", extraOptions = {}) | |||||||
|         isProtected: !!extraOptions.isProtected, |         isProtected: !!extraOptions.isProtected, | ||||||
|         type: extraOptions.type, |         type: extraOptions.type, | ||||||
|         mime: extraOptions.mime, |         mime: extraOptions.mime, | ||||||
|         dateCreated: extraOptions.dateCreated, |         utcDateCreated: extraOptions.utcDateCreated, | ||||||
|         isExpanded: extraOptions.isExpanded, |         isExpanded: extraOptions.isExpanded, | ||||||
|         notePosition: extraOptions.notePosition |         notePosition: extraOptions.notePosition | ||||||
|     }; |     }; | ||||||
| @@ -302,9 +302,9 @@ async function saveNoteRevision(note) { | |||||||
|     const revisionCutoff = dateUtils.dateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); |     const revisionCutoff = dateUtils.dateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); | ||||||
|  |  | ||||||
|     const existingNoteRevisionId = await sql.getValue( |     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) { |     if (!existingNoteRevisionId && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) { | ||||||
|         await new NoteRevision({ |         await new NoteRevision({ | ||||||
| @@ -315,8 +315,8 @@ async function saveNoteRevision(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 | ||||||
|             dateModifiedFrom: note.dateModified, |             utcDateModifiedFrom: note.utcDateModified, | ||||||
|             dateModifiedTo: dateUtils.nowDate() |             utcDateModifiedTo: dateUtils.nowDate() | ||||||
|         }).save(); |         }).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 |     // it's better to not use repository for this because it will complain about saving protected notes | ||||||
|     // out of protected session |     // 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(() => { | sqlInit.dbReady.then(() => { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ const cls = require('./cls'); | |||||||
| async function saveSourceId(sourceId) { | async function saveSourceId(sourceId) { | ||||||
|     await sql.insert("source_ids", { |     await sql.insert("source_ids", { | ||||||
|         sourceId: sourceId, |         sourceId: sourceId, | ||||||
|         dateCreated: dateUtils.nowDate() |         utcDateCreated: dateUtils.nowDate() | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     await refreshSourceIds(); |     await refreshSourceIds(); | ||||||
| @@ -30,7 +30,7 @@ async function generateSourceId() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function refreshSourceIds() { | 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 = []; | let allSourceIds = []; | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ async function addEntitySync(entityName, entityId, sourceId) { | |||||||
|     await sql.replace("sync", { |     await sql.replace("sync", { | ||||||
|         entityName: entityName, |         entityName: entityName, | ||||||
|         entityId: entityId, |         entityId: entityId, | ||||||
|         syncDate: dateUtils.nowDate(), |         utcSyncDate: dateUtils.nowDate(), | ||||||
|         sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId() |         sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId() | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| @@ -78,7 +78,7 @@ async function fillSyncRows(entityName, entityKey, condition = '') { | |||||||
|                 entityName: entityName, |                 entityName: entityName, | ||||||
|                 entityId: entityId, |                 entityId: entityId, | ||||||
|                 sourceId: "SYNC_FILL", |                 sourceId: "SYNC_FILL", | ||||||
|                 syncDate: dateUtils.nowDate() |                 utcSyncDate: dateUtils.nowDate() | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -55,7 +55,7 @@ async function updateEntity(sync, entity, sourceId) { | |||||||
| async function updateNote(entity, sourceId) { | async function updateNote(entity, sourceId) { | ||||||
|     const origNote = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [entity.noteId]); |     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.transactional(async () => { | ||||||
|             await sql.replace("notes", entity); |             await sql.replace("notes", entity); | ||||||
|  |  | ||||||
| @@ -71,7 +71,7 @@ async function updateNote(entity, sourceId) { | |||||||
| async function updateNoteContent(entity, sourceId) { | async function updateNoteContent(entity, sourceId) { | ||||||
|     const origNoteContent = await sql.getRow("SELECT * FROM note_contents WHERE noteId = ?", [entity.noteId]); |     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'); |         entity.content = entity.content === null ? null : Buffer.from(entity.content, 'base64'); | ||||||
|  |  | ||||||
|         await sql.transactional(async () => { |         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]); |     const orig = await sql.getRowOrNull("SELECT * FROM branches WHERE branchId = ?", [entity.branchId]); | ||||||
|  |  | ||||||
|     await sql.transactional(async () => { |     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 |             // 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. |             // otherwise in case of full new sync we'll get all branches (even root) collapsed. | ||||||
|             if (orig) { |             if (orig) { | ||||||
| @@ -111,8 +111,8 @@ async function updateNoteRevision(entity, sourceId) { | |||||||
|  |  | ||||||
|     await sql.transactional(async () => { |     await sql.transactional(async () => { | ||||||
|         // we update note revision even if date modified to is the same because the only thing which might have changed |         // 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 |         // is the protected status (and correnspondingly title and content) which doesn't affect the utcDateModifiedTo | ||||||
|         if (orig === null || orig.dateModifiedTo <= entity.dateModifiedTo) { |         if (orig === null || orig.utcDateModifiedTo <= entity.utcDateModifiedTo) { | ||||||
|             entity.content = entity.content === null ? null : Buffer.from(entity.content, 'base64'); |             entity.content = entity.content === null ? null : Buffer.from(entity.content, 'base64'); | ||||||
|  |  | ||||||
|             await sql.replace('note_revisions', entity); |             await sql.replace('note_revisions', entity); | ||||||
| @@ -142,7 +142,7 @@ async function updateOptions(entity, sourceId) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     await sql.transactional(async () => { |     await sql.transactional(async () => { | ||||||
|         if (orig === null || orig.dateModified < entity.dateModified) { |         if (orig === null || orig.utcDateModified < entity.utcDateModified) { | ||||||
|             await sql.replace('options', entity); |             await sql.replace('options', entity); | ||||||
|  |  | ||||||
|             await syncTableService.addOptionsSync(entity.name, sourceId); |             await syncTableService.addOptionsSync(entity.name, sourceId); | ||||||
| @@ -155,7 +155,7 @@ async function updateOptions(entity, sourceId) { | |||||||
| async function updateRecentNotes(entity, sourceId) { | async function updateRecentNotes(entity, sourceId) { | ||||||
|     const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE branchId = ?", [entity.branchId]); |     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.transactional(async () => { | ||||||
|             await sql.replace('recent_notes', entity); |             await sql.replace('recent_notes', entity); | ||||||
|  |  | ||||||
| @@ -167,7 +167,7 @@ async function updateRecentNotes(entity, sourceId) { | |||||||
| async function updateLink(entity, sourceId) { | async function updateLink(entity, sourceId) { | ||||||
|     const origLink = await sql.getRow("SELECT * FROM links WHERE linkId = ?", [entity.linkId]); |     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.transactional(async () => { | ||||||
|             await sql.replace("links", entity); |             await sql.replace("links", entity); | ||||||
|  |  | ||||||
| @@ -181,7 +181,7 @@ async function updateLink(entity, sourceId) { | |||||||
| async function updateAttribute(entity, sourceId) { | async function updateAttribute(entity, sourceId) { | ||||||
|     const origAttribute = await sql.getRow("SELECT * FROM attributes WHERE attributeId = ?", [entity.attributeId]); |     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.transactional(async () => { | ||||||
|             await sql.replace("attributes", entity); |             await sql.replace("attributes", entity); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user