Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
81436bee by wurstsalat at 2022-09-29T23:01:58+02:00
perf: SearchView: Update calendar only if widget is visible

This avoids unnecessary database queries when switching chats

- - - - -


2 changed files:

- gajim/gtk/chat_page.py
- gajim/gtk/search_view.py


Changes:

=====================================
gajim/gtk/chat_page.py
=====================================
@@ -155,7 +155,10 @@ def _on_chat_selected(self,
                           jid: JID) -> None:
 
         self._chat_stack.show_chat(account, jid)
-        self._search_view.set_context(account, jid)
+
+        if self._search_revealer.get_reveal_child():
+            self._search_view.set_context(account, jid)
+
         self.emit('chat-selected', workspace_id, account, jid)
 
     def _on_chat_unselected(self, _chat_list_stack: ChatListStack) -> None:
@@ -170,7 +173,6 @@ def _on_search_history(self,
             self._search_view.set_context(self._chat_control.contact.account,
                                           self._chat_control.contact.jid)
 
-        self._search_view.clear()
         self._search_revealer.set_reveal_child(True)
         self._search_view.set_focus()
 


=====================================
gajim/gtk/search_view.py
=====================================
@@ -78,11 +78,10 @@ def __init__(self) -> None:
         app.ged.register_event_handler('account-disabled',
                                        ged.GUI1,
                                        self._on_account_state)
-        self._update_calendar()
         self.show_all()
 
     def _on_account_state(self, _event: Any) -> None:
-        self.clear()
+        self._clear()
 
     @staticmethod
     def _header_func(row: ResultRow, before: ResultRow) -> None:
@@ -100,9 +99,9 @@ def _header_func(row: ResultRow, before: ResultRow) -> None:
 
     def _on_hide_clicked(self, _button: Gtk.Button) -> None:
         self.emit('hide-search')
-        self.clear()
+        self._clear()
 
-    def clear(self) -> None:
+    def _clear(self) -> None:
         self._ui.search_entry.set_text('')
         self._clear_results()
 
@@ -357,6 +356,8 @@ 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: Optional[str], jid: Optional[JID]) -> None:
         self._account = account



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/81436bee717700bab968dc27f1ab6193509538c6

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/81436bee717700bab968dc27f1ab6193509538c6
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to