Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh folder when selecting it #939

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/ConversationList/ConversationList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ public class Mail.ConversationList : Gtk.Box {
cancellable.cancel ();
}

var cancellable = new GLib.Cancellable ();
this.cancellable = cancellable;

conversation_focused (null);
conversation_selected (null);

Expand All @@ -261,8 +264,6 @@ public class Mail.ConversationList : Gtk.Box {
list_store.remove_all ();
list_store.items_changed (0, previous_items, 0);

cancellable = new GLib.Cancellable ();

lock (this.folder_full_name_per_account) {
foreach (var folder_full_name_entry in this.folder_full_name_per_account) {
var current_account = folder_full_name_entry.key;
Expand Down Expand Up @@ -311,14 +312,21 @@ public class Mail.ConversationList : Gtk.Box {
}

list_store.items_changed (0, 0, list_store.get_n_items ());
refresh_folder.begin (cancellable);
}

public async void refresh_folder (GLib.Cancellable? cancellable = null) {
if (cancellable != null && cancellable.is_cancelled ()) {
return;
}

refresh_stack.set_visible_child_name ("spinner");
lock (folders) {
foreach (var folder in folders.values) {
try {
yield folder.refresh_info (GLib.Priority.DEFAULT, cancellable);
} catch (IOError.CANCELLED e) {
break;
} catch (Error e) {
warning ("Error fetching messages for '%s' from '%s': %s",
folder.display_name,
Expand Down