Daniel Brötzmann pushed to branch storage at gajim / gajim
Commits:
19b11589 by wurstsalat at 2024-04-10T23:24:49+02:00
perf: SearchView: Reduce database calls
- - - - -
2 changed files:
- gajim/data/gui/search_view.ui
- gajim/gtk/search_view.py
Changes:
=====================================
gajim/data/gui/search_view.ui
=====================================
@@ -185,6 +185,7 @@
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Browse history by
date</property>
<property name="popover">calendar_popover</property>
+ <signal name="clicked" handler="_on_calender_button_clicked"
swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
=====================================
gajim/gtk/search_view.py
=====================================
@@ -198,12 +198,12 @@ def _on_edge_reached(self,
self._add_results()
- def _update_calendar(self) -> None:
- if self._account is None and self._jid is None:
- self._ui.calendar_button.set_sensitive(False)
- return
+ def _on_calender_button_clicked(self, menu_button: Gtk.MenuButton) -> None:
+ if menu_button.get_active():
+ self._update_calendar()
- self._ui.calendar_button.set_sensitive(True)
+ def _update_calendar(self) -> None:
+ self._ui.calendar.clear_marks()
assert self._jid is not None
assert self._account is not None
@@ -282,8 +282,8 @@ def _select_date(self,
assert self._jid is not None
assert self._account is not None
- has_history = False
- while not has_history:
+ date_contains_messages = False
+ while not date_contains_messages:
if direction == Direction.PREV:
if end_date <= date:
return
@@ -294,11 +294,14 @@ def _select_date(self,
date = date + delta
if date == end_date:
break
- has_history = app.storage.archive.date_has_history(
+ date_contains_messages = app.storage.archive.date_has_history(
self._account, self._jid, date)
gtk_m = gtk_month(date.month)
- self._ui.calendar.select_month(gtk_m, date.year)
+ if gtk_m != month or date.year != year:
+ # Select month only if it's a different one
+ self._ui.calendar.select_month(gtk_m, date.year)
+
self._ui.calendar.select_day(date.day)
def _scroll_to_date(self, date: datetime) -> None:
@@ -340,12 +343,16 @@ def _on_row_activated(_listbox: SearchView, row:
ResultRow) -> None:
def set_focus(self) -> None:
self._ui.search_entry.grab_focus()
self._clear()
- self._update_calendar()
def set_context(self, account: str | None, jid: JID | None) -> None:
self._account = account
self._jid = jid
- self._update_calendar()
+
+ if self._account is None and self._jid is None:
+ self._ui.calendar_button.set_sensitive(False)
+ return
+
+ self._ui.calendar_button.set_sensitive(True)
class RowHeader(Gtk.Box):
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/19b11589741185c5977d1e5d4caca8d13116778d
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/19b11589741185c5977d1e5d4caca8d13116778d
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]