Unregister handlers related to displaying messages as pending

This commit is contained in:
fiaxh 2020-10-11 12:16:38 +02:00
parent f28aaac6da
commit 78138bf39b

View file

@ -87,6 +87,7 @@ public class MessageItemWidget : SizeRequestBin {
ulong realize_id = -1; ulong realize_id = -1;
ulong style_updated_id = -1; ulong style_updated_id = -1;
ulong marked_notify_handler_id = -1;
construct { construct {
this.add(label); this.add(label);
@ -186,12 +187,16 @@ public class MessageItemWidget : SizeRequestBin {
theme_dependent = true; theme_dependent = true;
} }
// Append "pending..." iff message has not been sent yet
if (message.direction == Message.DIRECTION_SENT && (message.marked == Message.Marked.SENDING || message.marked == Message.Marked.UNSENT)) { 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) { if (message.local_time.compare(new DateTime.now_utc().add_seconds(-10)) < 0) {
markup_text += " <span size='small' color='%s'>%s</span>".printf(gray_color, "pending…"); markup_text += " <span size='small' color='%s'>%s</span>".printf(gray_color, "pending…");
message.bind_property("marked", this, "marked"); // Update the label as soon as the sent state changes
this.notify["marked"].connect(() => { var binding = message.bind_property("marked", this, "marked");
marked_notify_handler_id = this.notify["marked"].connect(() => {
binding.unbind();
this.disconnect(marked_notify_handler_id);
update_label(); update_label();
}); });
} else { } else {