diff options
author | Philipp Hörist <philipp@hoerist.com> | 2022-10-03 00:51:33 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2022-10-03 21:11:54 +0300 |
commit | 17d05ee08499698dc002380da4c8690a046e8454 (patch) | |
tree | 231e3a2bd36517ee37eebfe4a73b921c63de2ce0 | |
parent | 25af863a278059c5abd02a0a67fb2ed4cf303051 (diff) |
refactor: ChatPage: Check selected chat instead of active
-rw-r--r-- | gajim/gtk/chat_list_stack.py | 6 | ||||
-rw-r--r-- | gajim/gtk/chat_page.py | 4 | ||||
-rw-r--r-- | gajim/gtk/main.py | 4 |
3 files changed, 6 insertions, 8 deletions
diff --git a/gajim/gtk/chat_list_stack.py b/gajim/gtk/chat_list_stack.py index 00475c57f..d892a17d2 100644 --- a/gajim/gtk/chat_list_stack.py +++ b/gajim/gtk/chat_list_stack.py @@ -133,13 +133,11 @@ class ChatListStack(Gtk.Stack, EventHelper): return self._chat_lists[workspace_id] - def is_chat_active(self, account: str, jid: JID) -> bool: + def is_chat_selected(self, account: str, jid: JID) -> bool: chat = self.get_selected_chat() if chat is None: return False - if chat.account != account or chat.jid != jid: - return False - return chat.is_active + return chat.account == account and chat.jid == jid def _on_filter_changed(self, _filter: ChatFilter, name: str) -> None: chat_list = cast(ChatList, self.get_visible_child()) diff --git a/gajim/gtk/chat_page.py b/gajim/gtk/chat_page.py index 3d9ea6542..05cada0de 100644 --- a/gajim/gtk/chat_page.py +++ b/gajim/gtk/chat_page.py @@ -273,8 +273,8 @@ class ChatPage(Gtk.Box): pinned=open_chat['pinned'], position=open_chat['position']) - def is_chat_active(self, account: str, jid: JID) -> bool: - return self._chat_list_stack.is_chat_active(account, jid) + def is_chat_selected(self, account: str, jid: JID) -> bool: + return self._chat_list_stack.is_chat_selected(account, jid) def restore_chat(self) -> None: if not self._closed_chat_memory: diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py index d02fee958..b7f086bb8 100644 --- a/gajim/gtk/main.py +++ b/gajim/gtk/main.py @@ -563,9 +563,9 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper): return self._workspace_side_bar.get_active_workspace() def is_chat_active(self, account: str, jid: JID) -> bool: - if not self.get_property('has-toplevel-focus'): + if not self.has_toplevel_focus(): return False - return self._chat_page.is_chat_active(account, jid) + return self._chat_page.is_chat_selected(account, jid) def highlight_dnd_targets(self, drag_row: Any, highlight: bool) -> None: css_class = 'dnd-target' |