From 172cf0d92bacf7066321f006b31bc0e268507dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Mon, 3 Oct 2022 21:43:38 +0200 Subject: refactor: ChatListRow: Move active check into ChatList --- gajim/gtk/chat_list.py | 6 ++++++ gajim/gtk/chat_list_row.py | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/gajim/gtk/chat_list.py b/gajim/gtk/chat_list.py index 1d4c07be7..4cb9479cc 100644 --- a/gajim/gtk/chat_list.py +++ b/gajim/gtk/chat_list.py @@ -544,6 +544,12 @@ class ChatList(Gtk.ListBox, EventHelper): row.reset_unread() return + control = app.window.get_control() + if (app.window.is_active() and + row.is_selected() and + control.get_autoscroll()): + return + row.add_unread(event.msgtxt) def _on_message_received(self, event: MessageEventT) -> None: diff --git a/gajim/gtk/chat_list_row.py b/gajim/gtk/chat_list_row.py index 6783c3557..65743f7d5 100644 --- a/gajim/gtk/chat_list_row.py +++ b/gajim/gtk/chat_list_row.py @@ -191,11 +191,6 @@ class ChatListRow(Gtk.ListBoxRow): def is_pinned(self) -> bool: return self._pinned - @property - def is_active(self) -> bool: - return (self.is_selected() and - self.get_toplevel().get_property('is-active')) - @property def unread_count(self) -> int: if (self.contact.is_groupchat and not self.contact.can_notify() and @@ -309,12 +304,6 @@ class ChatListRow(Gtk.ListBoxRow): get_uf_relative_time(self.timestamp)) def add_unread(self, text: str) -> None: - control = app.window.get_control() - if (self.is_active and - control.is_loaded(self.account, self.jid) and - control.get_autoscroll()): - return - self._unread_count += 1 self._update_unread() app.storage.cache.set_unread_count( -- cgit v1.2.3