From 828718141a11ff2ba5c9a507b82d27624193da19 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 20 Sep 2019 09:12:53 +0300 Subject: [PATCH] ui: return valid values in ListingTrait::coordinates By convention the valid values at any time of a cursor_pos in mail listings is in self.new_cursor_pos, which the listing compares with self.cursor_pos to detect position changes. Returning self.cursor_pos values with coordinates() is invalid. --- ui/src/components/mail/listing/compact.rs | 5 +---- ui/src/components/mail/listing/conversations.rs | 5 +---- ui/src/components/mail/listing/plain.rs | 2 +- ui/src/components/mail/listing/thread.rs | 6 +++--- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index f381b49c..ecbec4ad 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -101,7 +101,7 @@ pub struct CompactListing { impl ListingTrait for CompactListing { fn coordinates(&self) -> (usize, usize, Option) { - (self.cursor_pos.0, self.cursor_pos.1, None) + (self.new_cursor_pos.0, self.new_cursor_pos.1, None) } fn set_coordinates(&mut self, coordinates: (usize, usize, Option)) { self.new_cursor_pos = (coordinates.0, coordinates.1, 0); @@ -498,9 +498,6 @@ impl CompactListing { self.dirty = false; return; }; - context - .replies - .push_back(UIEvent::RefreshMailbox((self.cursor_pos.0, folder_hash))); // Get mailbox as a reference. // diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index 87ba45d8..1c00dafa 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -104,7 +104,7 @@ pub struct ConversationsListing { impl ListingTrait for ConversationsListing { fn coordinates(&self) -> (usize, usize, Option) { - (self.cursor_pos.0, self.cursor_pos.1, None) + (self.new_cursor_pos.0, self.new_cursor_pos.1, None) } fn set_coordinates(&mut self, coordinates: (usize, usize, Option)) { @@ -532,9 +532,6 @@ impl ConversationsListing { self.dirty = false; return; }; - context - .replies - .push_back(UIEvent::RefreshMailbox((self.cursor_pos.0, folder_hash))); // Get mailbox as a reference. // diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index 617466bd..5667774c 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -88,7 +88,7 @@ pub struct PlainListing { impl ListingTrait for PlainListing { fn coordinates(&self) -> (usize, usize, Option) { - (self.cursor_pos.0, self.cursor_pos.1, None) + (self.new_cursor_pos.0, self.new_cursor_pos.1, None) } fn set_coordinates(&mut self, coordinates: (usize, usize, Option)) { self.new_cursor_pos = (coordinates.0, coordinates.1, 0); diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index 6a1169e2..d29bccb0 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -51,9 +51,9 @@ pub struct ThreadListing { impl ListingTrait for ThreadListing { fn coordinates(&self) -> (usize, usize, Option) { ( - self.cursor_pos.0, - self.cursor_pos.1, - Some(self.locations[self.cursor_pos.2]), + self.new_cursor_pos.0, + self.new_cursor_pos.1, + Some(self.locations[self.new_cursor_pos.2]), ) } fn set_coordinates(&mut self, coordinates: (usize, usize, Option)) {