diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-12-14 18:46:12 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-12-14 18:57:52 +0200 |
commit | 2e38ea11e21d93c5d8bb4d53c4a0f34681ecf4da (patch) | |
tree | 44ad4d9d1645e0a448dd79bdfefcec3ec3fe9f81 /ui/src/components | |
parent | 18a8d22b85375c4b4cecd00a1aafda670fc1f19e (diff) |
melib: make MailBackend::is_online() return Result<()>
Return Result<()> instead of bool to indicate connection status in order
to be able to show errors to user.
Diffstat (limited to 'ui/src/components')
-rw-r--r-- | ui/src/components/mail/listing.rs | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index ed80ec08..bd705499 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -295,29 +295,39 @@ impl Component for Listing { } if right_component_width == total_cols { - if !context.is_online(self.cursor_pos.0) { + if let Err(err) = context.is_online(self.cursor_pos.0) { clear_area(grid, area); - write_string_to_grid( - "offline", + let (x, _) = write_string_to_grid( + "offline: ", grid, Color::Byte(243), Color::Default, Attr::Default, - area, + (set_x(upper_left, mid + 1), bottom_right), + None, + ); + write_string_to_grid( + &err.to_string(), + grid, + Color::Red, + Color::Default, + Attr::Default, + (set_x(upper_left, x + 1), bottom_right), None, ); context.dirty_areas.push_back(area); return; + } else { + self.component.draw(grid, area, context); } - self.component.draw(grid, area, context); } else if right_component_width == 0 { self.draw_menu(grid, area, context); } else { self.draw_menu(grid, (upper_left, (mid, get_y(bottom_right))), context); - if !context.is_online(self.cursor_pos.0) { + if let Err(err) = context.is_online(self.cursor_pos.0) { clear_area(grid, (set_x(upper_left, mid + 1), bottom_right)); - write_string_to_grid( - "offline", + let (x, _) = write_string_to_grid( + "offline: ", grid, Color::Byte(243), Color::Default, @@ -325,11 +335,20 @@ impl Component for Listing { (set_x(upper_left, mid + 1), bottom_right), None, ); + write_string_to_grid( + &err.to_string(), + grid, + Color::Red, + Color::Default, + Attr::Default, + (set_x(upper_left, x + 1), bottom_right), + None, + ); context.dirty_areas.push_back(area); - return; + } else { + self.component + .draw(grid, (set_x(upper_left, mid + 1), bottom_right), context); } - self.component - .draw(grid, (set_x(upper_left, mid + 1), bottom_right), context); } self.dirty = false; } |