From 4e1311dfa9944fc04089037783db6a0a6eef7345 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Mon, 20 Mar 2023 15:40:44 -0600 Subject: Improve database performance while reconnecting and syncing Also move some tasks to low priority idle queue so they won't block UI updates --- .../conversation_selector/conversation_selector_row.vala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'main/src/ui') diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index 6ef61b3c..1bcf6962 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -225,7 +225,21 @@ public class ConversationSelectorRow : ListBoxRow { label.attributes = copy; } + private bool update_read_pending = false; + private bool update_read_pending_force = false; protected void update_read(bool force_update = false) { + if (force_update) update_read_pending_force = true; + if (update_read_pending) return; + update_read_pending = true; + Idle.add(() => { + update_read_pending = false; + update_read_pending_force = false; + update_read_idle(update_read_pending_force); + return Source.REMOVE; + }, Priority.LOW); + } + + private void update_read_idle(bool force_update = false) { int current_num_unread = stream_interactor.get_module(ChatInteraction.IDENTITY).get_num_unread(conversation); if (num_unread == current_num_unread && !force_update) return; num_unread = current_num_unread; -- cgit v1.2.3-70-g09d2