Commit 11ff1e70 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

fix: Chat: Display corrections for /me messages correctly

Fixes #10933
parent 5462da5a
......@@ -349,6 +349,7 @@ class MessageUpdated(ApplicationEvent):
account: str
jid: JID
msgtxt: str
nickname: Optional[str]
properties: Any
correct_id: str
......
......@@ -313,9 +313,11 @@ def _mam_message_received(self,
correct_id = parse_correction(properties)
if correct_id is not None:
nickname = properties.muc_nickname or properties.nickname
app.ged.raise_event(MessageUpdated(account=self._account,
jid=jid,
msgtxt=properties.body,
nickname=nickname,
properties=properties,
correct_id=correct_id))
app.storage.archive.store_message_correction(
......
......@@ -192,9 +192,11 @@ def _message_received(self,
correct_id = parse_correction(properties)
if correct_id is not None:
nickname = properties.muc_nickname or properties.nickname
event = MessageUpdated(account=self._account,
jid=event_attr['jid'],
msgtxt=msgtxt,
nickname=nickname,
properties=properties,
correct_id=correct_id)
......
......@@ -433,7 +433,7 @@ def _on_message_updated(self, event: events.MessageUpdated) -> None:
return
if event.correct_id == row.message_id:
row.set_message_text(event.msgtxt)
row.set_message_text(event.msgtxt, event.nickname)
def _on_message_moderated(self, event: events.MessageModerated) -> None:
row = self._chats.get((event.account, event.jid))
......
......@@ -327,7 +327,8 @@ def process_event(self, event: events.ApplicationEvent) -> None:
getattr(self, method_name)(event)
def _on_message_updated(self, event: events.MessageUpdated) -> None:
self.conversation_view.correct_message(event.correct_id, event.msgtxt)
self.conversation_view.correct_message(
event.correct_id, event.msgtxt, event.nickname)
def _on_message_moderated(self, event: events.MessageModerated) -> None:
text = get_retraction_text(
......
......@@ -415,7 +415,7 @@ def _on_message_sent(self, event: events.MessageSent) -> None:
if event.correct_id:
self.conversation_view.correct_message(
event.correct_id, event.message)
event.correct_id, event.message, self.get_our_nick())
return
self.add_message(event.message,
......
......@@ -60,8 +60,10 @@ def add_with_styling(self,
self.add_content(result)
def _add_action_phrase(self, text: str, nickname: str):
self.clear()
widget = PlainWidget(self._account, self._selectable)
widget.add_action_phrase(text, nickname)
widget.show_all()
self.add(widget)
def add_content(self, content: ContentT) -> None:
......
......@@ -417,9 +417,9 @@ def set_retracted(self, text: str) -> None:
self._message_widget.add_with_styling(text)
self.get_style_context().add_class('retracted-message')
def set_correction(self, text: str) -> None:
def set_correction(self, text: str, nickname: Optional[str]) -> None:
if not isinstance(self._message_widget, PreviewWidget):
self._message_widget.add_with_styling(text)
self._message_widget.add_with_styling(text, nickname)
self._has_receipt = False
self._message_icons.set_receipt_icon_visible(False)
......
......@@ -487,10 +487,14 @@ def scroll_to_end(self, force: bool = False) -> None:
if self.autoscroll or force:
GLib.idle_add(self.emit, 'scroll-to-end')
def correct_message(self, correct_id: str, text: str) -> None:
def correct_message(self,
correct_id: str,
text: str,
nickname: Optional[str]
) -> None:
message_row = self._get_row_by_message_id(correct_id)
if message_row is not None:
message_row.set_correction(text)
message_row.set_correction(text, nickname)
message_row.set_merged(False)
def show_message_retraction(self, stanza_id: str, text: str) -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment