From c0c9e1df14be3cc74023ae0ef1130d9f53da46e0 Mon Sep 17 00:00:00 2001 From: Andrei Voronin Date: Mon, 25 Mar 2024 17:04:26 +0300 Subject: [PATCH] Added spinner for resynck Added spinner for resynck. Added stack with button and spinner. After pushing the button button will be replaced witn spinning spinner indicating process. Spinner will be replaced with button after receiving message from server. !Sometimes spinner will stop to spin, but the process will still be running. You can start animation again by pressing on the spinner. It is known issue with gtk spinner --- .../src/ui/contact_details/history_provider.vala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main/src/ui/contact_details/history_provider.vala b/main/src/ui/contact_details/history_provider.vala index 558ce3fd..9cdb5dca 100644 --- a/main/src/ui/contact_details/history_provider.vala +++ b/main/src/ui/contact_details/history_provider.vala @@ -28,9 +28,21 @@ public class HistoryProvider : Plugins.ContactDetailsProvider, Object { entity_info.has_feature.begin(conversation.account, conversation.counterpart, Xmpp.MessageArchiveManagement.NS_URI, (_, res) => { bool can_do_mam = entity_info.has_feature.end(res); if (can_do_mam) { + Button resync_button = new Button.with_label(RESYNC_LABEL); - contact_details.add("Permissions", RESYNC_DESC_LABEL, "", resync_button); + Stack resync_stack = new Stack(); + Gtk.Spinner spinner = new Gtk.Spinner(); + + resync_stack.visible = true; + contact_details.add("Permissions", RESYNC_DESC_LABEL, "", resync_stack); + resync_stack.add_child(spinner); + resync_stack.add_child(resync_button); + resync_stack.set_visible_child(resync_button); + resync_button.clicked.connect(() => { + resync_stack.set_visible_child(spinner); + spinner.start(); + if (!sync_cancellables.has_key(conversation.account)) { sync_cancellables[conversation.account] = new HashMap(); } @@ -40,6 +52,8 @@ public class HistoryProvider : Plugins.ContactDetailsProvider, Object { var history_sync = stream_interactor.get_module(MessageProcessor.IDENTITY).history_sync; history_sync.fetch_history.begin(conversation.account, conversation.counterpart.bare_jid, sync_cancellables[conversation.account][conversation.counterpart.bare_jid], (_, res) => { history_sync.fetch_everything.end(res); + spinner.stop(); + resync_stack.set_visible_child(resync_button); sync_cancellables[conversation.account].unset(conversation.counterpart.bare_jid); }); }