Skip to content

Commit

Permalink
Fix category & tags change
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-128 committed Feb 5, 2025
1 parent 1fcee35 commit b85c54d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion qBitControl/Components/ChangeCategoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ struct ChangeCategoryView: View {
qBittorrent.getCategories(completionHandler: { _categories in
var categories = _categories.map { $0.value }
categories.sort { $0.name < $1.name }

self.categories = categories
clearSelectedCategories()
})
}

private func clearSelectedCategories() {
if let onCategoryChange = self.onCategoryChange {
if !categories.map({ $0.name }).contains(category) {
onCategoryChange(Category(name: "Uncategorized", savePath: ""))
}
}
}

var body: some View {
VStack {
Form {
Expand Down Expand Up @@ -68,6 +76,7 @@ struct ChangeCategoryView: View {
}

categories.remove(atOffsets: offsets)
self.clearSelectedCategories()
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion qBitControl/Components/ChangeTagsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct ChangeTagsView: View {
func getTags() {
qBittorrent.getTags(completionHandler: { tags in
self.allTags = tags.sorted()
self.clearSelectedTags()
})
}

Expand Down Expand Up @@ -67,7 +68,6 @@ struct ChangeTagsView: View {
qBittorrent.removeTag(tag: tag, then: { status in
if(status == 200) {
self.getTags()
self.clearSelectedTags()
}
})
}
Expand Down

0 comments on commit b85c54d

Please sign in to comment.