From d091a6c3cd0812873bcdef53c51a2f60e12f2b8a Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 5 Apr 2020 16:19:56 +0200 Subject: [PATCH] Add keyboard shortcut (up key) to activate last message correction --- libdino/src/service/message_correction.vala | 10 ++++++- libdino/src/service/message_processor.vala | 2 +- main/data/message_item_widget_edit_mode.ui | 4 +-- .../ui/chat_input/chat_input_controller.vala | 13 ++++++++ .../conversation_view.vala | 18 +++++++++++ .../message_widget.vala | 24 ++++++++++++++- main/src/ui/conversation_view_controller.vala | 2 +- .../src/module/xep/0203_delayed_delivery.vala | 30 ++++++++++--------- .../xep/0313_message_archive_management.vala | 2 +- 9 files changed, 84 insertions(+), 21 deletions(-) diff --git a/libdino/src/service/message_correction.vala b/libdino/src/service/message_correction.vala index 320c0b7e..90d0580f 100644 --- a/libdino/src/service/message_correction.vala +++ b/libdino/src/service/message_correction.vala @@ -91,6 +91,12 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { public override string[] after_actions { get { return after_actions_const; } } public override async bool run(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) { + if (conversation.type_ != Conversation.Type.CHAT) { + // Don't process messages or corrections from MUC history + DateTime? mam_delay = Xep.DelayedDelivery.get_time_for_message(stanza, message.from.bare_jid); + if (mam_delay != null) return false; + } + string? replace_id = Xep.LastMessageCorrection.get_replace_id(stanza); if (replace_id == null) { if (!last_messages.has_key(conversation)) { @@ -126,9 +132,11 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { message.edit_to = replace_id; on_received_correction(conversation, current_correction_message_id); + + return true; } - return true; + return false; } private void on_received_correction(Conversation conversation, int message_id) { diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala index 0120fcd4..6bc4fc9e 100644 --- a/libdino/src/service/message_processor.vala +++ b/libdino/src/service/message_processor.vala @@ -122,7 +122,7 @@ public class MessageProcessor : StreamInteractionModule, Object { if (id == null) return; StanzaNode? delay_node = message.stanza.get_deep_subnode(mam_flag.ns_ver + ":result", "urn:xmpp:forward:0:forwarded", "urn:xmpp:delay:delay"); if (delay_node == null) return; - DateTime? time = DelayedDelivery.Module.get_time_for_node(delay_node); + DateTime? time = DelayedDelivery.get_time_for_node(delay_node); if (time == null) return; mam_times[account][id] = time; diff --git a/main/data/message_item_widget_edit_mode.ui b/main/data/message_item_widget_edit_mode.ui index 8a4faca2..b33d8aa3 100644 --- a/main/data/message_item_widget_edit_mode.ui +++ b/main/data/message_item_widget_edit_mode.ui @@ -51,13 +51,13 @@ True - Cancel + Cancel True - Update message + Update message True