From f3137bafa0bb8bf390dd6ddad50bcb6c72d02545 Mon Sep 17 00:00:00 2001 From: S3L3CT3DLoves <153332410+S3L3CT3DLoves@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:48:10 +0100 Subject: [PATCH] Now deleted tags are removed from QuickEdit --- plugins/QuickEdit/README.md | 1 - plugins/QuickEdit/easytag.yml | 2 +- plugins/QuickEdit/quickedit_config.js | 18 +++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/QuickEdit/README.md b/plugins/QuickEdit/README.md index 15bbd51..2900f1b 100644 --- a/plugins/QuickEdit/README.md +++ b/plugins/QuickEdit/README.md @@ -26,7 +26,6 @@ ToDo Features for the future - Background color for each group -- Config export/restore to file # Configuration diff --git a/plugins/QuickEdit/easytag.yml b/plugins/QuickEdit/easytag.yml index 57ee0ee..719ec05 100644 --- a/plugins/QuickEdit/easytag.yml +++ b/plugins/QuickEdit/easytag.yml @@ -1,7 +1,7 @@ name: EasyTag description: UI plugin to add shortcuts for commonly used tags url: https://github.com/stashapp/CommunityScripts -version: 0.15.1 +version: 0.16 # requires: CommunityScriptsUILibrary ui: diff --git a/plugins/QuickEdit/quickedit_config.js b/plugins/QuickEdit/quickedit_config.js index 4fe2927..532ae72 100644 --- a/plugins/QuickEdit/quickedit_config.js +++ b/plugins/QuickEdit/quickedit_config.js @@ -61,13 +61,21 @@ class ButtonsConfig{ moveTag(tagId, newGroup){ const tag = this.getTag(tagId) if(tag){ - this.getTag(tagId).group = newGroup + tag.group = newGroup this.saveConfig() return true } return false } + removeTag(tagId){ + const tag = this.getTag(tagId) + if(tag){ + this.tags.splice(this.tags.indexOf(tag),1) + this.saveConfig() + } + } + orderTags(){ let orderedTags = this.tags.sort((tagA, tagB) => { let nameA = tagA.getDisplayName() @@ -351,6 +359,14 @@ class ButtonsConfigUI{ tagElement.appendChild(tagButtonsContainer) listContainer.appendChild(tagElement) } + + // Cleanup, if tags have been deleted + const existingTagIds = this.allStashTags.map(tag => Number(tag.id)) + for (const tag of this.buttonsConfig.tags) { + if(!existingTagIds.includes(tag.stashId)){ + this.buttonsConfig.removeTag(tag.stashId) + } + } this.refreshTagGroups() }) }