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


Commits:
95cd9b4c by wurstsalat at 2022-09-30T21:03:05+02:00
fix: Update chat actions when account state changes

Fixes #11184

- - - - -


1 changed file:

- gajim/gtk/chat_stack.py


Changes:

=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -15,6 +15,7 @@
 from __future__ import annotations
 
 from typing import Optional
+from typing import Union
 
 import sys
 import logging
@@ -147,6 +148,8 @@ def __init__(self):
             ('message-received', 85, self._on_message_received),
             ('gc-message-received', 85, self._on_message_received),
             ('muc-disco-update', 85, self._on_muc_disco_update),
+            ('account-connected', 85, self._on_account_state),
+            ('account-disconnected', 85, self._on_account_state),
         ])
 
     def _get_current_contact(self) -> ChatContactT:
@@ -189,6 +192,7 @@ def show_chat(self, account: str, jid: JID) -> None:
         self._message_action_box.switch_contact(self._current_contact)
 
         self._update_base_actions(self._current_contact)
+
         if isinstance(self._current_contact, GroupchatContact):
             self._current_contact.multi_connect({
                 'user-joined': self._on_user_joined,
@@ -333,6 +337,26 @@ def _on_muc_disco_update(self, event: 
events.MucDiscoUpdate) -> None:
 
         self._update_group_chat_actions(self._current_contact)
 
+    def _on_account_state(self,
+                          event: Union[events.AccountConnected,
+                                       events.AccountDisconnected]
+                          ) -> None:
+
+        if self._current_contact is None:
+            return
+
+        if event.account != self._current_contact.account:
+            return
+
+        self._update_base_actions(self._current_contact)
+
+        if isinstance(self._current_contact, GroupchatContact):
+            self._update_group_chat_actions(self._current_contact)
+        elif isinstance(self._current_contact, GroupchatParticipant):
+            self._update_participant_actions(self._current_contact)
+        else:
+            self._update_chat_actions(self._current_contact)
+
     def _on_message_received(self, event: events.MessageReceived) -> None:
         if not event.msgtxt or event.properties.is_sent_carbon:
             return



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/95cd9b4c3b23d1b20e5c32ec66ef7cdd899c9b4b

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/95cd9b4c3b23d1b20e5c32ec66ef7cdd899c9b4b
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