Skip to content

Commit

Permalink
Added spinner for resynck
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Aristofan-Kif authored and mxlgv committed Mar 26, 2024
1 parent 9ae30a0 commit b80498a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main/src/ui/contact_details/history_provider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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<Jid, Cancellable>();
}
Expand All @@ -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);
});
}
Expand Down

0 comments on commit b80498a

Please sign in to comment.