Skip to content

Commit

Permalink
Now deleted tags are removed from QuickEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
S3L3CT3DLoves committed Jan 13, 2025
1 parent 1507dc0 commit f3137ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 0 additions & 1 deletion plugins/QuickEdit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ToDo

Features for the future
- Background color for each group
- Config export/restore to file


# Configuration
Expand Down
2 changes: 1 addition & 1 deletion plugins/QuickEdit/easytag.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
18 changes: 17 additions & 1 deletion plugins/QuickEdit/quickedit_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
})
}
Expand Down

0 comments on commit f3137ba

Please sign in to comment.