Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2022-09-30 22:03:00 +0300
committerwurstsalat <mailtrash@posteo.de>2022-09-30 22:03:05 +0300
commit95cd9b4c3b23d1b20e5c32ec66ef7cdd899c9b4b (patch)
treeed9923f3f43110dbc73a8d87106044e468197825
parentdd218cc3e5eed3db8d56d74e7e087d616efee5a4 (diff)
fix: Update chat actions when account state changes
Fixes #11184
-rw-r--r--gajim/gtk/chat_stack.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/gajim/gtk/chat_stack.py b/gajim/gtk/chat_stack.py
index 2820a2a50..53a4b28a3 100644
--- a/gajim/gtk/chat_stack.py
+++ b/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 @@ class ChatStack(Gtk.Stack, EventHelper):
('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 @@ class ChatStack(Gtk.Stack, EventHelper):
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 @@ class ChatStack(Gtk.Stack, EventHelper):
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