diff options
Diffstat (limited to 'main/src/ui/conversation_content_view')
3 files changed, 15 insertions, 17 deletions
diff --git a/main/src/ui/conversation_content_view/call_widget.vala b/main/src/ui/conversation_content_view/call_widget.vala index ab047196..3d6b250b 100644 --- a/main/src/ui/conversation_content_view/call_widget.vala +++ b/main/src/ui/conversation_content_view/call_widget.vala @@ -111,6 +111,10 @@ namespace Dino.Ui { incoming_call_revealer.reveal_child = true; } + private void on_time_update_timeout() { + if (time_update_handler_id != 0) update_call_state(); + } + private void update_call_state() { incoming_call_revealer.reveal_child = false; incoming_call_revealer.remove_css_class("incoming"); @@ -156,14 +160,7 @@ namespace Dino.Ui { string duration = get_duration_string((new DateTime.now_utc()).difference(call.local_time)); subtitle_label.label = _("Started %s ago").printf(duration); - time_update_handler_id = Timeout.add_seconds(get_next_time_change() + 1, () => { - if (time_update_handler_id != 0) { - Source.remove(time_update_handler_id); - time_update_handler_id = 0; - update_call_state(); - } - return true; - }); + time_update_handler_id = Dino.WeakTimeout.add_seconds_once(get_next_time_change() + 1, this, on_time_update_timeout); break; case Call.State.OTHER_DEVICE: diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala index 5d86f6c7..3b818b44 100644 --- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala +++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala @@ -173,14 +173,14 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, set_widget(widget, Plugins.WidgetType.GTK4, 3); } + private void on_time_update_timeout() { + if (main_grid.parent != null) update_time(); + } + private void update_time() { time_label.label = get_relative_time(item.time.to_local()).to_string(); - time_update_timeout = Timeout.add_seconds((int) get_next_time_change(item.time), () => { - if (this.main_grid.parent == null) return false; - update_time(); - return false; - }); + time_update_timeout = Dino.WeakTimeout.add_seconds_once((int) get_next_time_change(item.time), this, on_time_update_timeout); } private void update_name_label() { diff --git a/main/src/ui/conversation_content_view/quote_widget.vala b/main/src/ui/conversation_content_view/quote_widget.vala index 23b62e6a..b267e6bc 100644 --- a/main/src/ui/conversation_content_view/quote_widget.vala +++ b/main/src/ui/conversation_content_view/quote_widget.vala @@ -41,12 +41,13 @@ namespace Dino.Ui.Quote { this.author_jid = content_item.jid; } + private void on_display_time_timeout() { + if (display_time_timeout != 0) update_display_time(); + } + private void update_display_time() { this.display_time = ConversationItemSkeleton.get_relative_time(message_time.to_local()); - display_time_timeout = Timeout.add_seconds((int) ConversationItemSkeleton.get_next_time_change(message_time), () => { - if (display_time_timeout != 0) update_display_time(); - return false; - }); + display_time_timeout = Dino.WeakTimeout.add_seconds_once((int) ConversationItemSkeleton.get_next_time_change(message_time), this, on_display_time_timeout); } public override void dispose() { |