Philipp Hörist pushed to branch master at gajim / gajim


Commits:
fa79e9be by Philipp Hörist at 2023-05-09T21:49:21+02:00
refactor: Chatstates: Simplify and use client attribute

- - - - -


1 changed file:

- gajim/common/modules/chatstates.py


Changes:

=====================================
gajim/common/modules/chatstates.py
=====================================
@@ -88,8 +88,10 @@ def __init__(self, con: types.Client) -> None:
         self._blocked: list[JID] = []
         self._enabled = False
 
-        self._con.connect_signal('state-changed', 
self._on_client_state_changed)
-        self._con.connect_signal('resume-failed', 
self._on_client_resume_failed)
+        self._client.connect_signal('state-changed',
+                                    self._on_client_state_changed)
+        self._client.connect_signal('resume-failed',
+                                    self._on_client_resume_failed)
 
     def _on_client_resume_failed(self,
                                  _client: types.Client,
@@ -120,7 +122,7 @@ def _set_enabled(self, value: bool) -> None:
                 2, self._check_last_interaction)
         else:
             self.cleanup()
-            self._con.get_module('Contacts').force_chatstate_update()
+            self._client.get_module('Contacts').force_chatstate_update()
 
     @ensure_enabled
     def _presence_received(self,
@@ -251,7 +253,7 @@ def get_active_chatstate(self,
 
         if not contact.is_groupchat:
             # Don’t send chatstates to ourself
-            if self._con.get_own_jid().bare_match(contact.jid):
+            if self._client.is_own_jid(contact.jid):
                 return None
 
             if not contact.supports(Namespace.CHATSTATES):
@@ -284,7 +286,7 @@ def set_chatstate_delayed(self,
         # User starts writing again.
 
         # Don’t send chatstates to ourself
-        if self._con.get_own_jid().bare_match(contact.jid):
+        if self._client.is_own_jid(contact.jid):
             return
 
         self.remove_delay_timeout(contact)
@@ -294,7 +296,7 @@ def set_chatstate_delayed(self,
     @ensure_enabled
     def set_chatstate(self, contact: types.ChatContactT, state: State) -> None:
         # Don’t send chatstates to ourself
-        if self._con.get_own_jid().bare_match(contact.jid):
+        if self._client.is_own_jid(contact.jid):
             return
 
         if contact.jid in self._blocked:
@@ -364,7 +366,7 @@ def _send_chatstate(self,
                                   chatstate=chatstate.value,
                                   play_sound=False)
 
-        self._con.send_message(message)
+        self._client.send_message(message)
 
     @ensure_enabled
     def set_mouse_activity(self,



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/fa79e9be46bbb0bce80e2283cbd57a96dc75d108
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to