mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 07:39:10 +00:00
fix: remove unnecessary update calls
This commit is contained in:
@@ -419,15 +419,16 @@ class Library:
|
||||
make_transient(entry)
|
||||
return entry
|
||||
|
||||
def get_entry_full(self, entry_id: int) -> Entry | None:
|
||||
def get_entry_full(
|
||||
self, entry_id: int, with_fields: bool = True, with_tags: bool = True
|
||||
) -> Entry | None:
|
||||
"""Load entry and join with all joins and all tags."""
|
||||
with Session(self.engine) as session:
|
||||
statement = select(Entry).where(Entry.id == entry_id)
|
||||
statement = (
|
||||
statement.outerjoin(Entry.text_fields)
|
||||
.outerjoin(Entry.datetime_fields)
|
||||
.outerjoin(Entry.tags)
|
||||
)
|
||||
if with_fields:
|
||||
statement = statement.outerjoin(Entry.text_fields).outerjoin(Entry.datetime_fields)
|
||||
if with_tags:
|
||||
statement = statement.outerjoin(Entry.tags)
|
||||
statement = statement.options(
|
||||
selectinload(Entry.text_fields),
|
||||
selectinload(Entry.datetime_fields),
|
||||
|
||||
@@ -115,7 +115,7 @@ class FieldContainers(QWidget):
|
||||
tags=entry.tags,
|
||||
)
|
||||
|
||||
self.cached_entries = [self.lib.get_entry_full(entry.id)]
|
||||
self.cached_entries = [self.lib.get_entry_full(entry.id, with_fields=False)]
|
||||
entry_ = self.cached_entries[0]
|
||||
container_len: int = len(entry_.fields)
|
||||
container_index = 0
|
||||
@@ -129,6 +129,8 @@ class FieldContainers(QWidget):
|
||||
)
|
||||
container_index += 1
|
||||
container_len += 1
|
||||
if categories:
|
||||
self.tags_updated.emit()
|
||||
# Write field container(s)
|
||||
for index, field in enumerate(entry_.fields, start=container_index):
|
||||
self.write_container(index, field, is_mixed=False)
|
||||
@@ -410,18 +412,12 @@ class FieldContainers(QWidget):
|
||||
)
|
||||
container.set_inner_widget(inner_widget)
|
||||
|
||||
inner_widget.updated.connect(
|
||||
lambda: (
|
||||
self.write_tag_container(index, tags, category_tag),
|
||||
self.update_from_entry(self.cached_entries[0]),
|
||||
)
|
||||
)
|
||||
inner_widget.updated.connect(lambda: (self.update_from_entry(self.cached_entries[0])))
|
||||
else:
|
||||
text = "<i>Mixed Data</i>"
|
||||
inner_widget = TextWidget("Mixed Tags", text)
|
||||
container.set_inner_widget(inner_widget)
|
||||
|
||||
self.tags_updated.emit()
|
||||
container.set_edit_callback()
|
||||
container.set_remove_callback()
|
||||
container.setHidden(False)
|
||||
|
||||
@@ -98,10 +98,10 @@ class TagBoxWidget(FieldWidget):
|
||||
selected=self.driver.selected,
|
||||
)
|
||||
|
||||
if tag_id in (TAG_FAVORITE, TAG_ARCHIVED):
|
||||
self.driver.update_badges(self.driver.selected)
|
||||
|
||||
for entry_id in self.driver.selected:
|
||||
self.driver.lib.remove_tags_from_entry(entry_id, tag_id)
|
||||
|
||||
self.updated.emit()
|
||||
|
||||
if tag_id in (TAG_FAVORITE, TAG_ARCHIVED):
|
||||
self.driver.update_badges(self.driver.selected)
|
||||
|
||||
Reference in New Issue
Block a user