diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-25 23:14:24 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-26 13:11:49 +0300 |
commit | 91ae539de1730d735f6137f36e2f5da57225cfce (patch) | |
tree | 01a385311fa33f18d63a27d9e599a10a3cab59db /ui/src/components/mail | |
parent | f27b815aa79e234c299a4a1255c7f001ec68e1cd (diff) |
Small fixes
Diffstat (limited to 'ui/src/components/mail')
-rw-r--r-- | ui/src/components/mail/view.rs | 3 | ||||
-rw-r--r-- | ui/src/components/mail/view/thread.rs | 32 |
2 files changed, 24 insertions, 11 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 154bd01a..315970aa 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -341,6 +341,7 @@ impl Component for MailView { if !account.contains_key(self.coordinates.2) { /* The envelope has been renamed or removed, so wait for the appropriate event to * arrive */ + self.dirty = false; return; } let (hash, is_seen) = { @@ -638,7 +639,6 @@ impl Component for MailView { self.subview = None; } }; - self.dirty = false; } match self.mode { ViewMode::Subview if self.subview.is_some() => { @@ -656,6 +656,7 @@ impl Component for MailView { } } } + self.dirty = false; } fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index b3cf3e27..f84ad207 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -414,11 +414,14 @@ impl ThreadView { let bottom_right = bottom_right!(area); let (width, height) = self.content.size(); if height == 0 { - clear_area(grid, area); context.dirty_areas.push_back(area); return; } let rows = (get_y(bottom_right) - get_y(upper_left)).wrapping_div(2); + if rows == 0 { + context.dirty_areas.push_back(area); + return; + } if let Some(mvm) = self.movement.take() { match mvm { PageMovement::PageUp => { @@ -751,7 +754,10 @@ impl ThreadView { let upper_left = upper_left!(area); let bottom_right = bottom_right!(area); - let rows = (get_y(bottom_right) - get_y(upper_left) + 1) / 2; + let rows = (get_y(bottom_right).saturating_sub(get_y(upper_left) + 1)) / 2; + if rows == 0 { + return; + } let page_no = (self.new_cursor_pos).wrapping_div(rows); let top_idx = page_no * rows; @@ -765,7 +771,10 @@ impl ThreadView { let area = (set_y(upper_left, y), bottom_right); let upper_left = upper_left!(area); - let rows = (get_y(bottom_right) - get_y(upper_left) + 1) / 2; + let rows = (get_y(bottom_right).saturating_sub(get_y(upper_left) + 1)) / 2; + if rows == 0 { + return; + } let page_no = (self.new_cursor_pos).wrapping_div(rows); let top_idx = page_no * rows; copy_area( @@ -875,6 +884,7 @@ impl Component for ThreadView { fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { let total_cols = width!(area); if self.entries.is_empty() { + self.dirty = false; return; } @@ -891,6 +901,7 @@ impl Component for ThreadView { if self.entries.len() == 1 { self.mailview.draw(grid, area, context); + self.dirty = false; return; } @@ -899,6 +910,7 @@ impl Component for ThreadView { } else { self.draw_horz(grid, area, context); } + self.dirty = false; } fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { match event { @@ -959,6 +971,7 @@ impl Component for ThreadView { UIEvent::Input(Key::Up) => { if self.cursor_pos > 0 { self.new_cursor_pos = self.new_cursor_pos.saturating_sub(1); + self.dirty = true; } return true; } @@ -966,24 +979,25 @@ impl Component for ThreadView { let height = self.visible_entries.iter().flat_map(|v| v.iter()).count(); if height > 0 && self.new_cursor_pos + 1 < height { self.new_cursor_pos += 1; + self.dirty = true; } return true; } UIEvent::Input(ref key) if *key == shortcuts["prev_page"] => { self.movement = Some(PageMovement::PageUp); - self.set_dirty(); + self.dirty = true; } UIEvent::Input(ref key) if *key == shortcuts["next_page"] => { self.movement = Some(PageMovement::PageDown); - self.set_dirty(); + self.dirty = true; } UIEvent::Input(ref key) if *key == Key::Home => { self.movement = Some(PageMovement::Home); - self.set_dirty(); + self.dirty = true; } UIEvent::Input(ref key) if *key == Key::End => { self.movement = Some(PageMovement::End); - self.set_dirty(); + self.dirty = true; } UIEvent::Input(Key::Char('\n')) => { if self.entries.len() < 2 { @@ -1066,9 +1080,7 @@ impl Component for ThreadView { false } fn is_dirty(&self) -> bool { - (self.cursor_pos != self.new_cursor_pos) - || self.dirty - || (self.show_mailview && self.mailview.is_dirty()) + self.dirty || (self.show_mailview && self.mailview.is_dirty()) } fn set_dirty(&mut self) { self.dirty = true; |