From 16cc84be99ecd2a494fc14027149804f4bbe1dd1 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 26 Jun 2021 17:32:40 +0200 Subject: [PATCH] add back utcDateModified to Attribute and Branch becca entities --- src/becca/becca_loader.js | 4 ++-- src/becca/entities/abstract_entity.js | 3 +-- src/becca/entities/attribute.js | 6 +++++- src/becca/entities/branch.js | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/becca/becca_loader.js b/src/becca/becca_loader.js index ed45b9484..7b8af0eb7 100644 --- a/src/becca/becca_loader.js +++ b/src/becca/becca_loader.js @@ -29,11 +29,11 @@ function load() { new Note(row); } - for (const row of sql.iterateRows(`SELECT branchId, noteId, parentNoteId, prefix, notePosition, isExpanded FROM branches WHERE isDeleted = 0`, [])) { + for (const row of sql.iterateRows(`SELECT branchId, noteId, parentNoteId, prefix, notePosition, isExpanded, utcDateModified FROM branches WHERE isDeleted = 0`, [])) { new Branch(row); } - for (const row of sql.iterateRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position FROM attributes WHERE isDeleted = 0`, [])) { + for (const row of sql.iterateRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position, utcDateModified FROM attributes WHERE isDeleted = 0`, [])) { new Attribute(row); } diff --git a/src/becca/entities/abstract_entity.js b/src/becca/entities/abstract_entity.js index 7b7c176f6..93631eac3 100644 --- a/src/becca/entities/abstract_entity.js +++ b/src/becca/entities/abstract_entity.js @@ -35,8 +35,7 @@ class AbstractEntity { } getUtcDateChanged() { - // FIXME - return this.utcDateModified || this.utcDateCreated || "FAKE"; + return this.utcDateModified || this.utcDateCreated; } get becca() { diff --git a/src/becca/entities/attribute.js b/src/becca/entities/attribute.js index fa2a2fe73..18c0d0e34 100644 --- a/src/becca/entities/attribute.js +++ b/src/becca/entities/attribute.js @@ -28,6 +28,8 @@ class Attribute extends AbstractEntity { this.value = row.value; /** @param {boolean} */ this.isInheritable = !!row.isInheritable; + /** @param {string} */ + this.utcDateModified = row.utcDateModified; if (this.attributeId) { this.becca.attributes[this.attributeId] = this; @@ -136,6 +138,8 @@ class Attribute extends AbstractEntity { this.isInheritable = false; } + this.utcDateModified = dateUtils.utcNowDateTime(); + super.beforeSaving(); this.becca.attributes[this.attributeId] = this; @@ -150,7 +154,7 @@ class Attribute extends AbstractEntity { position: this.position, value: this.value, isInheritable: this.isInheritable, - utcDateModified: dateUtils.utcNowDateTime(), + utcDateModified: this.utcDateModified, isDeleted: false }; } diff --git a/src/becca/entities/branch.js b/src/becca/entities/branch.js index 2848667e4..683c1dace 100644 --- a/src/becca/entities/branch.js +++ b/src/becca/entities/branch.js @@ -26,6 +26,8 @@ class Branch extends AbstractEntity { this.notePosition = row.notePosition; /** @param {boolean} */ this.isExpanded = !!row.isExpanded; + /** @param {string} */ + this.utcDateModified = row.utcDateModified; if (this.branchId === 'root') { return;