From 37f95dd86db67826eba48957f8e864c7fde14eb7 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 4 Apr 2019 00:30:30 +0300 Subject: [PATCH] ui: fix crash when ThreadView is initiated without a ready mailbox --- ui/src/components/mail/listing/compact.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 8ecbb956..17ab9e54 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -110,12 +110,7 @@ impl CompactListing { /// chosen. fn refresh_mailbox(&mut self, context: &mut Context) { self.dirty = true; - if self.cursor_pos == self.new_cursor_pos { - self.view.update(context); - } else { - self.view = ThreadView::new(self.cursor_pos, None, context); - } - + let old_cursor_pos = self.cursor_pos; if !(self.cursor_pos.0 == self.new_cursor_pos.0 && self.cursor_pos.1 == self.new_cursor_pos.1) { @@ -149,6 +144,12 @@ impl CompactListing { return; } } + if old_cursor_pos == self.new_cursor_pos { + self.view.update(context); + } else { + self.view = ThreadView::new(self.new_cursor_pos, None, context); + } + let mailbox = &context.accounts[self.cursor_pos.0][self.cursor_pos.1] .as_ref() .unwrap();