mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 08:45:50 +01:00
entities are now changed only if entity hash changed which will limit number of events emitted
This commit is contained in:
@@ -18,13 +18,21 @@ class Entity {
|
||||
this[this.constructor.primaryKeyName] = utils.newEntityId();
|
||||
}
|
||||
|
||||
const origHash = this.hash;
|
||||
|
||||
this.hash = this.generateHash();
|
||||
|
||||
this.isChanged = origHash !== this.hash;
|
||||
}
|
||||
|
||||
generateHash() {
|
||||
let contentToHash = "";
|
||||
|
||||
for (const propertyName of this.constructor.hashedProperties) {
|
||||
contentToHash += "|" + this[propertyName];
|
||||
}
|
||||
|
||||
this["hash"] = utils.hash(contentToHash).substr(0, 10);
|
||||
return utils.hash(contentToHash).substr(0, 10);
|
||||
}
|
||||
|
||||
async save() {
|
||||
|
||||
Reference in New Issue
Block a user