Skip to content

Commit ec20289

Browse files
authored
fix: update entry cache when toggling tags (#1135)
1 parent 278adc1 commit ec20289

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/tagstudio/core/library/alchemy/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ def __repr__(self) -> str:
163163
def __hash__(self) -> int:
164164
return hash(self.id)
165165

166+
def __eq__(self, value: object) -> bool:
167+
if not isinstance(value, Tag):
168+
return False
169+
return self.id == value.id
170+
166171
def __lt__(self, other: "Tag") -> bool:
167172
return self.name < other.name
168173

src/tagstudio/qt/mixed/field_containers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ def update_toggled_tag(self, tag_id: int, toggle_value: bool):
149149
tag = self.lib.get_tag(tag_id)
150150
if not tag:
151151
return
152-
new_tags = (
153-
entry.tags.union({tag}) if toggle_value else {t for t in entry.tags if t.id != tag_id}
154-
)
155-
self.update_granular(entry_tags=new_tags, entry_fields=entry.fields, update_badges=False)
152+
if toggle_value:
153+
entry.tags.add(tag)
154+
else:
155+
entry.tags.discard(tag)
156+
157+
self.update_granular(entry_tags=entry.tags, entry_fields=entry.fields, update_badges=False)
156158

157159
def hide_containers(self):
158160
"""Hide all field and tag containers."""

0 commit comments

Comments
 (0)