From 976b2aa6f5a41b40f5dff04d6f844d132b59a224 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 28 Jan 2020 22:39:44 +0100 Subject: [PATCH] got rid of "origParentNoteId" since it's not needed anymore --- src/entities/branch.js | 13 ------------- src/services/note_cache.js | 14 +++++++------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/entities/branch.js b/src/entities/branch.js index a4022f88a..95edccdb5 100644 --- a/src/entities/branch.js +++ b/src/entities/branch.js @@ -28,13 +28,6 @@ class Branch extends Entity { // notePosition is not part of hash because it would produce a lot of updates in case of reordering static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "deleteId", "prefix"]; } - constructor(row = {}) { - super(row); - - // used to detect move in note tree - this.origParentNoteId = this.parentNoteId; - } - /** @returns {Note|null} */ async getNote() { return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); @@ -65,12 +58,6 @@ class Branch extends Entity { } } - // cannot be static! - updatePojo(pojo) { - // FIXME remove - delete pojo.origParentNoteId; - } - createClone(parentNoteId, notePosition) { return new Branch({ noteId: this.noteId, diff --git a/src/services/note_cache.js b/src/services/note_cache.js index 74b339c01..c19910be8 100644 --- a/src/services/note_cache.js +++ b/src/services/note_cache.js @@ -477,14 +477,14 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED else if (entityName === 'branches') { const branch = entity; - // first we remove records for original placement (if they exist) - childToParent[branch.noteId] = childToParent[branch.noteId] || []; - childToParent[branch.noteId] = childToParent[branch.noteId].filter(noteId => noteId !== branch.origParentNoteId); + if (branch.isDeleted) { + childToParent[branch.noteId] = childToParent[branch.noteId] || []; + childToParent[branch.noteId] = childToParent[branch.noteId].filter(noteId => noteId !== branch.parentNoteId); - delete prefixes[branch.noteId + '-' + branch.origParentNoteId]; - delete childParentToBranchId[branch.noteId + '-' + branch.origParentNoteId]; - - if (!branch.isDeleted) { + delete prefixes[branch.noteId + '-' + branch.parentNoteId]; + delete childParentToBranchId[branch.noteId + '-' + branch.parentNoteId]; + } + else { // ... and then we create new records if (branch.prefix) { prefixes[branch.noteId + '-' + branch.parentNoteId] = branch.prefix;