Philipp Hörist pushed to branch message-replies at gajim / gajim
Commits:
a2d3e4a2 by Philipp Hörist at 2024-04-28T21:25:58+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,8 @@ 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.has_cancelable_action():
+ self._message_action_box.cancel_action()
return True
return False
@@ -862,12 +858,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,20 @@ def insert_as_quote(self, text: str, *, clear: bool =
False) -> None:
self.msg_textview.clear()
self.msg_textview.insert_as_quote(text)
+ def has_cancelable_action(self) -> bool:
+ return self.is_correcting or self.is_in_reply_mode
+
+ 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/a2d3e4a2cdfb386d03f383ef8cbe46d5671e08a6
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/a2d3e4a2cdfb386d03f383ef8cbe46d5671e08a6
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]