diff --git a/meli/src/accounts.rs b/meli/src/accounts.rs index 731dafeb..739d9cf2 100644 --- a/meli/src/accounts.rs +++ b/meli/src/accounts.rs @@ -348,11 +348,11 @@ impl Account { .into_iter() .collect::>(); for f in ref_mailboxes.values_mut() { + if default_mailbox.remove(f.path()) { + self.settings.default_mailbox = Some(f.hash()); + } if let Some(conf) = self.settings.mailbox_confs.get_mut(f.path()) { mailbox_conf_hash_set.remove(f.path()); - if default_mailbox.remove(f.path()) { - self.settings.default_mailbox = Some(f.hash()); - } conf.mailbox_conf.usage = if f.special_usage() != SpecialUsageMailbox::Normal { Some(f.special_usage()) } else { diff --git a/meli/src/mail/listing.rs b/meli/src/mail/listing.rs index 430ebfc7..06760e23 100644 --- a/meli/src/mail/listing.rs +++ b/meli/src/mail/listing.rs @@ -2832,6 +2832,16 @@ impl Listing { cmd_buf: String::with_capacity(4), }; ret.component.realize(ret.id().into(), context); + { + let _new_val = ret.cursor_pos.account; + if let Some(idx) = context.accounts[_new_val] + .default_mailbox() + .and_then(|h| ret.accounts[_new_val].entry_by_hash(h)) + { + ret.cursor_pos.menu = MenuEntryCursor::Mailbox(idx); + ret.menu_cursor_pos.menu = MenuEntryCursor::Mailbox(idx); + } + } ret.change_account(context); ret } @@ -3335,6 +3345,20 @@ impl Listing { index_style: previous_index_styles.get(&f.hash).copied(), }) .collect::<_>(); + if let ( + ListingComponent::Offline(_), + MenuEntryCursor::Mailbox(ref mut idx), + Some(default), + ) = ( + &self.component, + &mut self.cursor_pos.menu, + context.accounts[self.cursor_pos.account] + .default_mailbox() + .and_then(|h| self.accounts[self.cursor_pos.account].entry_by_hash(h)), + ) { + *idx = default; + self.menu_cursor_pos.menu = MenuEntryCursor::Mailbox(default); + } match self.cursor_pos.menu { MenuEntryCursor::Mailbox(idx) => { // Account might have no mailboxes yet if it's offline