diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-04-10 18:58:09 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:44 +0300 |
commit | b993375fa0737dcfbd1aca5e765210969a143282 (patch) | |
tree | 5a2ca54476a0897ac700d23a413807e40bb690a8 /ui/src/components | |
parent | 42a512d01084691c67cb074f9863cfd1e50ad978 (diff) |
ui: put INBOX first in AccountMenu
Diffstat (limited to 'ui/src/components')
-rw-r--r-- | ui/src/components/mail.rs | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/ui/src/components/mail.rs b/ui/src/components/mail.rs index 0cf85ed3..503c669b 100644 --- a/ui/src/components/mail.rs +++ b/ui/src/components/mail.rs @@ -39,8 +39,6 @@ struct AccountMenuEntry { name: String, // Index in the config account vector. index: usize, - // Each entry and its index in the account - entries: Vec<(usize, Folder)>, } /// The account sidebar. @@ -67,13 +65,6 @@ impl AccountMenu { .map(|(i, a)| AccountMenuEntry { name: a.name().to_string(), index: i, - entries: { - let mut entries = Vec::with_capacity(a.len()); - for (idx, acc) in a.list_folders().into_iter().enumerate() { - entries.push((idx, acc)); - } - entries - }, }) .collect(); AccountMenu { @@ -96,16 +87,27 @@ impl AccountMenu { if cfg!(feature = "debug_log") && !is_valid_area!(area) { eprintln!("BUG: invalid area in print_account"); } + // Each entry and its index in the account + let entries: Vec<(usize, Folder)> = { + let a = &context.accounts[a.index]; + let mut entries = Vec::with_capacity(a.len()); + for (idx, acc) in a.list_folders().into_iter().enumerate() { + entries.push((idx, acc)); + } + entries + }; let upper_left = upper_left!(area); let bottom_right = bottom_right!(area); let highlight = self.cursor.map(|(x, _)| x == a.index).unwrap_or(false); - let mut parents: Vec<Option<usize>> = vec![None; a.entries.len()]; + let mut parents: Vec<Option<usize>> = vec![None; entries.len()]; - for (idx, e) in a.entries.iter().enumerate() { - for c in e.1.children() { - parents[*c] = Some(idx); + for (idx, e) in entries.iter().enumerate() { + for &c in e.1.children() { + if c < parents.len() { + parents[c] = Some(idx); + } } } let mut roots = Vec::new(); @@ -137,6 +139,9 @@ impl AccountMenu { index: usize, //account index context: &mut Context, ) { + if root >= entries.len() { + return; + } let len = s.len(); match context.accounts[index].status(root) { Ok(_) => {} @@ -167,7 +172,7 @@ impl AccountMenu { } for r in roots { print( - r, &parents, &mut depth, &a.entries, &mut s, &mut inc, a.index, context, + r, &parents, &mut depth, &entries, &mut s, &mut inc, a.index, context, ); } @@ -274,6 +279,9 @@ impl Component for AccountMenu { UIEventType::StartupCheck(_) => { self.dirty = true; } + UIEventType::MailboxUpdate(_) => { + self.dirty = true; + } _ => {} } false |