mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
move entity hash to entity_changes table WIP
This commit is contained in:
@@ -109,9 +109,7 @@ class Attribute extends Entity {
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
if (this.isChanged) {
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
|
||||
createClone(type, name, value, isInheritable) {
|
||||
|
||||
@@ -57,9 +57,7 @@ class Branch extends Entity {
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
if (this.isChanged) {
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
|
||||
createClone(parentNoteId, notePosition) {
|
||||
|
||||
@@ -22,11 +22,6 @@ class Entity {
|
||||
|
||||
beforeSaving() {
|
||||
this.generateIdIfNecessary();
|
||||
|
||||
const origHash = this.hash;
|
||||
|
||||
this.hash = this.generateHash();
|
||||
this.isChanged = origHash !== this.hash;
|
||||
}
|
||||
|
||||
generateIdIfNecessary() {
|
||||
|
||||
@@ -143,8 +143,7 @@ class Note extends Entity {
|
||||
noteId: this.noteId,
|
||||
content: content,
|
||||
dateModified: dateUtils.localNowDateTime(),
|
||||
utcDateModified: dateUtils.utcNowDateTime(),
|
||||
hash: utils.hash(this.noteId + "|" + content.toString())
|
||||
utcDateModified: dateUtils.utcNowDateTime()
|
||||
};
|
||||
|
||||
if (this.isProtected) {
|
||||
@@ -158,7 +157,9 @@ class Note extends Entity {
|
||||
|
||||
sql.upsert("note_contents", "noteId", pojo);
|
||||
|
||||
entityChangesService.addNoteContentEntityChange(this.noteId);
|
||||
const hash = utils.hash(this.noteId + "|" + content.toString());
|
||||
|
||||
entityChangesService.addEntityChange('note_contents', this.noteId, hash);
|
||||
}
|
||||
|
||||
setJsonContent(content) {
|
||||
@@ -904,10 +905,8 @@ class Note extends Entity {
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
if (this.isChanged) {
|
||||
this.dateModified = dateUtils.localNowDateTime();
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
this.dateModified = dateUtils.localNowDateTime();
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
|
||||
// cannot be static!
|
||||
|
||||
@@ -106,8 +106,7 @@ class NoteRevision extends Entity {
|
||||
const pojo = {
|
||||
noteRevisionId: this.noteRevisionId,
|
||||
content: content,
|
||||
utcDateModified: dateUtils.utcNowDateTime(),
|
||||
hash: utils.hash(this.noteRevisionId + "|" + content)
|
||||
utcDateModified: dateUtils.utcNowDateTime()
|
||||
};
|
||||
|
||||
if (this.isProtected) {
|
||||
@@ -121,15 +120,15 @@ class NoteRevision extends Entity {
|
||||
|
||||
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
|
||||
|
||||
entityChangesService.addNoteRevisionContentEntityChange(this.noteRevisionId);
|
||||
const hash = utils.hash(this.noteRevisionId + "|" + content);
|
||||
|
||||
entityChangesService.addEntityChange('note_revision_contents', this.noteRevisionId, hash);
|
||||
}
|
||||
|
||||
beforeSaving() {
|
||||
super.beforeSaving();
|
||||
|
||||
if (this.isChanged) {
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
|
||||
// cannot be static!
|
||||
|
||||
@@ -32,10 +32,8 @@ class Option extends Entity {
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
if (this.isChanged) {
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Option;
|
||||
module.exports = Option;
|
||||
|
||||
Reference in New Issue
Block a user