Philipp Hörist pushed to branch master at gajim / gajim
Commits:
3e2331ac by Philipp Hörist at 2024-11-18T22:37:49+01:00
new: StartChat: Improve loading time and add debug logging
- - - - -
1 changed file:
- gajim/gtk/start_chat.py
Changes:
=====================================
gajim/gtk/start_chat.py
=====================================
@@ -9,6 +9,7 @@
from typing import Generic
from typing import TypeVar
+import logging
from enum import Enum
from gi.repository import Gdk
@@ -64,6 +65,9 @@
V = TypeVar("V", bound=type[Gtk.Widget])
+log = logging.getLogger("gajim.gtk.start_chat")
+
+
class ChatTypeFilter(Enum):
ALL = "all"
CHAT = "chats"
@@ -188,6 +192,9 @@ def __init__(
self._initial_message[initial_jid] = initial_message
self._ui.search_entry.set_text(initial_jid)
+ self._contact_view.set_loading_finished()
+
+ log.debug("Loading dialog finished")
self.show()
def _cleanup(self, *args: Any) -> None:
@@ -217,6 +224,7 @@ def _add_accounts(self) -> None:
self._accounts_store.append([None, *account])
def _add_contacts(self, scale: int) -> None:
+ log.debug("Loading contacts")
show_account = len(self._accounts) > 1
for account, _label in self._accounts:
client = app.get_client(account)
@@ -247,7 +255,12 @@ def _add_contacts(self, scale: int) -> None:
)
self._contact_view.add(item)
+ log.debug(
+ "Loading contacts finished, model count %s",
self._contact_view.get_count()
+ )
+
def _add_groupchats(self, scale: int) -> None:
+ log.debug("Loading groupchats")
show_account = len(self._accounts) > 1
for account, _label in self._accounts:
client = app.get_client(account)
@@ -268,6 +281,11 @@ def _add_groupchats(self, scale: int) -> None:
)
self._contact_view.add(item)
+ log.debug(
+ "Loading groupchats finished, model count %s",
+ self._contact_view.get_count(),
+ )
+
def _add_new_contact_items(self, scale: int) -> None:
for account, _label in self._accounts:
show_account = len(self._accounts) > 1
@@ -822,7 +840,7 @@ def __init__(self) -> None:
property_name="name",
)
sorter = Gtk.StringSorter(expression=expression)
- self._sort_model = Gtk.SortListModel(model=self._model, sorter=sorter)
+ self._sort_model = Gtk.SortListModel(sorter=sorter)
self._custom_filter = Gtk.CustomFilter.new(self._filter_func)
@@ -853,6 +871,12 @@ def do_unroot(self) -> None:
del self._custom_filter
app.check_finalize(self)
+ def set_loading_finished(self) -> None:
+ self._sort_model.set_model(self._model)
+
+ def get_count(self) -> int:
+ return self._model.get_n_items()
+
def _on_filter_items_changed(
self, filter_model: Gtk.FilterListModel, _pos: int, _removed: int,
_added: int
) -> None:
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3e2331acb01ad0a23547fc174f408cb35ba24d9a
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3e2331acb01ad0a23547fc174f408cb35ba24d9a
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]