From 124f7779c38862e140ac3207bbbf33ea0c913367 Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Wed, 16 Jun 2021 12:28:32 -0300 Subject: [PATCH] fix: remove recursive tag deletion --- .../ui_models/app_state/note_tags_state.ts | 12 +++--------- .../ui_models/app_state/notes_state.ts | 16 +++++----------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/ui_models/app_state/note_tags_state.ts b/app/assets/javascripts/ui_models/app_state/note_tags_state.ts index f263fcb7d..80b5273f8 100644 --- a/app/assets/javascripts/ui_models/app_state/note_tags_state.ts +++ b/app/assets/javascripts/ui_models/app_state/note_tags_state.ts @@ -198,15 +198,9 @@ export class NoteTagsState { async removeTagFromActiveNote(tag: SNTag): Promise { const { activeNote } = this; if (activeNote) { - const descendantTags = this.application.getTagDescendants(tag); - const tagsToRemove = [...descendantTags, tag]; - await Promise.all( - tagsToRemove.map(async (tag) => { - await this.application.changeItem(tag.uuid, (mutator) => { - mutator.removeItemAsRelationship(activeNote); - }); - }) - ); + await this.application.changeItem(tag.uuid, (mutator) => { + mutator.removeItemAsRelationship(activeNote); + }); this.application.sync(); this.reloadTags(); } diff --git a/app/assets/javascripts/ui_models/app_state/notes_state.ts b/app/assets/javascripts/ui_models/app_state/notes_state.ts index daa9881aa..66d1ad024 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_state.ts @@ -346,17 +346,11 @@ export class NotesState { async removeTagFromSelectedNotes(tag: SNTag): Promise { const selectedNotes = Object.values(this.selectedNotes); - const descendantTags = this.application.getTagDescendants(tag); - const tagsToRemove = [...descendantTags, tag]; - await Promise.all( - tagsToRemove.map(async (tag) => { - await this.application.changeItem(tag.uuid, (mutator) => { - for (const note of selectedNotes) { - mutator.removeItemAsRelationship(note); - } - }); - }) - ); + await this.application.changeItem(tag.uuid, (mutator) => { + for (const note of selectedNotes) { + mutator.removeItemAsRelationship(note); + } + }); this.application.sync(); }