From 7309c6f3ac4e580f197b4835d05bb011fa90780b Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 15 Jul 2020 15:08:56 +0200 Subject: Visually highlight pending messages, improve resending --- .../conversation_content_view/message_widget.vala | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'main/src/ui') diff --git a/main/src/ui/conversation_content_view/message_widget.vala b/main/src/ui/conversation_content_view/message_widget.vala index 13b48a1e..83d826e9 100644 --- a/main/src/ui/conversation_content_view/message_widget.vala +++ b/main/src/ui/conversation_content_view/message_widget.vala @@ -80,6 +80,7 @@ public class MessageItemWidget : SizeRequestBin { StreamInteractor stream_interactor; public ContentItem content_item; + public Message.Marked marked { get; set; } Label label = new Label("") { use_markup=true, xalign=0, selectable=true, wrap=true, wrap_mode=Pango.WrapMode.WORD_CHAR, vexpand=true, visible=true }; MessageItemEditMode? edit_mode = null; @@ -179,12 +180,30 @@ public class MessageItemWidget : SizeRequestBin { markup_text = @"" + markup_text + ""; } + string gray_color = Util.is_dark_theme(label) ? "#808080" : "#909090"; + if (message.edit_to != null) { - string color = Util.is_dark_theme(label) ? "#808080" : "#909090"; - markup_text += " (%s)".printf(color, _("edited")); + markup_text += " (%s)".printf(gray_color, _("edited")); theme_dependent = true; } + if (message.direction == Message.DIRECTION_SENT && (message.marked == Message.Marked.SENDING || message.marked == Message.Marked.UNSENT)) { + if (message.local_time.compare(new DateTime.now_utc().add_seconds(-10)) < 0) { + markup_text += " %s".printf(gray_color, "pending…"); + + message.bind_property("marked", this, "marked"); + this.notify["marked"].connect(() => { + update_label(); + }); + } else { + int time_diff = (- (int) message.local_time.difference(new DateTime.now_utc()) / 1000); + Timeout.add(10000 - time_diff, () => { + update_label(); + return false; + }); + } + } + if (theme_dependent && realize_id == -1) { realize_id = label.realize.connect(update_label); style_updated_id = label.style_updated.connect(update_label); -- cgit v1.2.3-70-g09d2