Philipp Hörist pushed to branch message-replies at gajim / gajim


Commits:
5e51aeee by Philipp Hörist at 2024-04-28T22:52:16+02:00
refactor: Improve MessageActionBox encapsulation

- - - - -


2 changed files:

- gajim/gtk/chat_stack.py
- gajim/gtk/message_actions_box.py


Changes:

=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -160,12 +160,7 @@ def process_escape(self) -> bool:
             self._chat_function_page.process_escape()
             return True
 
-        if self._message_action_box.is_correcting:
-            self._message_action_box.toggle_message_correction()
-            return True
-
-        if self._message_action_box.is_in_reply_mode:
-            self._message_action_box.disable_reply_mode()
+        if self._message_action_box.process_escape():
             return True
 
         return False
@@ -862,12 +857,9 @@ def _on_send_message(self) -> None:
 
         client.send_message(message_)
 
-        self._message_action_box.msg_textview.clear()
-        self._last_quoted_id = None
-        app.storage.drafts.set(contact, '')
+        self._message_action_box.reset_state_after_send()
 
-        if reply_data is not None:
-            self._message_action_box.disable_reply_mode()
+        self._last_quoted_id = None
 
     def get_last_message_id(self, contact: ChatContactT) -> str | None:
         return self._message_action_box.get_last_message_id(contact)


=====================================
gajim/gtk/message_actions_box.py
=====================================
@@ -242,6 +242,23 @@ def insert_as_quote(self, text: str, *, clear: bool = 
False) -> None:
             self.msg_textview.clear()
         self.msg_textview.insert_as_quote(text)
 
+    def process_escape(self) -> bool:
+        if not self.is_correcting and not self.is_in_reply_mode:
+            return False
+        self._cancel_action()
+        return True
+
+    def _cancel_action(self) -> None:
+        if self.is_correcting:
+            self.toggle_message_correction()
+        self.disable_reply_mode()
+
+    def reset_state_after_send(self) -> None:
+        self.msg_textview.clear()
+        self._cancel_action()
+        assert self._contact is not None
+        app.storage.drafts.set(self._contact, '')
+
     def toggle_message_correction(self) -> None:
         self.msg_textview.toggle_message_correction()
 



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

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


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to