[geary: 2/3] Fix UpdateMailboxCommand to work correctly when there is only a single mailbox
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 2/3] Fix UpdateMailboxCommand to work correctly when there is only a single mailbox
- Date: Wed, 20 Feb 2019 23:28:36 +0000 (UTC)
commit 843c31db74b0227118baaf43fd67331270a5d0ad
Author: Kristian Klausen <kristian klausen dk>
Date: Wed Feb 20 14:23:27 2019 +0100
Fix UpdateMailboxCommand to work correctly when there is only a single mailbox
This commit update UpdateMailboxCommand to use a new function
("replace_sender") to replace a existing mailbox, instead of
remove/insert, which doesn't work if the number of mailboxes is 1.
This fix two bugs (if number of mailboxes is 1):
1. The "name" couldn't be updated.
2. If you did change the address, the old mailbox wasn't removed.
See also #226
src/client/accounts/accounts-editor-edit-pane.vala | 6 ++----
src/engine/api/geary-account-information.vala | 7 +++++++
2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-edit-pane.vala
b/src/client/accounts/accounts-editor-edit-pane.vala
index c64a8362..3576a53d 100644
--- a/src/client/accounts/accounts-editor-edit-pane.vala
+++ b/src/client/accounts/accounts-editor-edit-pane.vala
@@ -605,15 +605,13 @@ internal class Accounts.UpdateMailboxCommand : Application.Command {
public async override void execute(GLib.Cancellable? cancellable) {
this.row.mailbox = this.new_mailbox;
- this.row.account.remove_sender(this.old_mailbox);
- this.row.account.insert_sender(this.mailbox_index, this.new_mailbox);
+ this.row.account.replace_sender(this.mailbox_index, this.new_mailbox);
this.row.account.changed();
}
public async override void undo(GLib.Cancellable? cancellable) {
this.row.mailbox = this.old_mailbox;
- this.row.account.remove_sender(this.new_mailbox);
- this.row.account.insert_sender(this.mailbox_index, this.old_mailbox);
+ this.row.account.replace_sender(this.mailbox_index, this.old_mailbox);
this.row.account.changed();
}
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index a3e68016..4efeab59 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -356,6 +356,13 @@ public class Geary.AccountInformation : BaseObject {
}
/**
+ * Replace a mailbox at the specified index.
+ */
+ public void replace_sender(int index, Geary.RFC822.MailboxAddress mailbox) {
+ this.mailboxes.set(index, mailbox);
+ }
+
+ /**
* Returns the configured path for a special folder type.
*
* This is used when Geary has found or created a special folder
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]