From ec202891b2ba06a2e5fd007e3d75195a2c3d37bb Mon Sep 17 00:00:00 2001 From: TheBobBobs <84781603+TheBobBobs@users.noreply.github.com> Date: Tue, 23 Sep 2025 23:06:46 +0000 Subject: [PATCH] fix: update entry cache when toggling tags (#1135) --- src/tagstudio/core/library/alchemy/models.py | 5 +++++ src/tagstudio/qt/mixed/field_containers.py | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/tagstudio/core/library/alchemy/models.py b/src/tagstudio/core/library/alchemy/models.py index 223dc021..7cebf62a 100644 --- a/src/tagstudio/core/library/alchemy/models.py +++ b/src/tagstudio/core/library/alchemy/models.py @@ -163,6 +163,11 @@ class Tag(Base): def __hash__(self) -> int: return hash(self.id) + def __eq__(self, value: object) -> bool: + if not isinstance(value, Tag): + return False + return self.id == value.id + def __lt__(self, other: "Tag") -> bool: return self.name < other.name diff --git a/src/tagstudio/qt/mixed/field_containers.py b/src/tagstudio/qt/mixed/field_containers.py index 1128e494..7f17dbf2 100644 --- a/src/tagstudio/qt/mixed/field_containers.py +++ b/src/tagstudio/qt/mixed/field_containers.py @@ -149,10 +149,12 @@ class FieldContainers(QWidget): tag = self.lib.get_tag(tag_id) if not tag: return - new_tags = ( - entry.tags.union({tag}) if toggle_value else {t for t in entry.tags if t.id != tag_id} - ) - self.update_granular(entry_tags=new_tags, entry_fields=entry.fields, update_badges=False) + if toggle_value: + entry.tags.add(tag) + else: + entry.tags.discard(tag) + + self.update_granular(entry_tags=entry.tags, entry_fields=entry.fields, update_badges=False) def hide_containers(self): """Hide all field and tag containers."""