mail/listing*: clear selection after perform_action()
parent
b5530860d2
commit
26b327d86a
|
@ -341,6 +341,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
}
|
||||
|
||||
fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]>;
|
||||
fn selection(&mut self) -> &mut HashMap<ThreadHash, bool>;
|
||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]>;
|
||||
fn redraw_threads_list(
|
||||
&mut self,
|
||||
|
@ -743,6 +744,14 @@ impl Component for Listing {
|
|||
| Action::Listing(a @ ListingAction::Tag(_)) => {
|
||||
let focused = self.component.get_focused_items(context);
|
||||
self.component.perform_action(context, focused, a);
|
||||
let mut row_updates: SmallVec<[ThreadHash; 8]> = SmallVec::new();
|
||||
for (k, v) in self.component.selection().iter_mut() {
|
||||
if *v {
|
||||
*v = false;
|
||||
row_updates.push(*k);
|
||||
}
|
||||
}
|
||||
self.component.row_updates().extend(row_updates.drain(..));
|
||||
self.component.set_dirty(true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -44,71 +44,78 @@ macro_rules! address_list {
|
|||
}
|
||||
|
||||
macro_rules! row_attr {
|
||||
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr) => {{
|
||||
let fg = if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.fg
|
||||
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
|
||||
ThemeAttribute {
|
||||
fg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.fg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.fg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_selected.fg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.fg
|
||||
} else {
|
||||
$color_cache.odd_unseen.fg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.fg
|
||||
} else {
|
||||
$color_cache.odd_unseen.fg
|
||||
}
|
||||
} else if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.fg
|
||||
$color_cache.odd.fg
|
||||
},
|
||||
bg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.bg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.bg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_selected.bg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.bg
|
||||
} else {
|
||||
$color_cache.odd_unseen.bg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.bg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.fg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.fg
|
||||
} else {
|
||||
$color_cache.odd.fg
|
||||
};
|
||||
let bg = if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.bg
|
||||
$color_cache.odd.bg
|
||||
},
|
||||
attrs: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.attrs
|
||||
} else {
|
||||
$color_cache.odd_highlighted.attrs
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_selected.attrs
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.attrs
|
||||
} else {
|
||||
$color_cache.odd_unseen.attrs
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.attrs
|
||||
} else {
|
||||
$color_cache.odd_highlighted.bg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_selected.bg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.bg
|
||||
} else {
|
||||
$color_cache.odd_unseen.bg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.bg
|
||||
} else {
|
||||
$color_cache.odd.bg
|
||||
};
|
||||
let attrs = if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.attrs
|
||||
} else {
|
||||
$color_cache.odd_highlighted.attrs
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_selected.attrs
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.attrs
|
||||
} else {
|
||||
$color_cache.odd_unseen.attrs
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.attrs
|
||||
} else {
|
||||
$color_cache.odd.attrs
|
||||
};
|
||||
ThemeAttribute { fg, bg, attrs }
|
||||
$color_cache.odd.attrs
|
||||
},
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -161,6 +168,10 @@ impl MailListingTrait for CompactListing {
|
|||
&mut self.row_updates
|
||||
}
|
||||
|
||||
fn selection(&mut self) -> &mut HashMap<ThreadHash, bool> {
|
||||
&mut self.selection
|
||||
}
|
||||
|
||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
||||
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
||||
let i = [self.get_thread_under_cursor(self.cursor_pos.2)];
|
||||
|
@ -981,17 +992,13 @@ impl CompactListing {
|
|||
return;
|
||||
}
|
||||
let idx = self.order[&thread_hash];
|
||||
let row_attr = if thread.unseen() > 0 {
|
||||
if idx % 2 == 0 {
|
||||
self.color_cache.even_unseen
|
||||
} else {
|
||||
self.color_cache.odd_unseen
|
||||
}
|
||||
} else if idx % 2 == 0 {
|
||||
self.color_cache.even
|
||||
} else {
|
||||
self.color_cache.odd
|
||||
};
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
idx % 2 == 0,
|
||||
thread.unseen() > 0,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
||||
let strings = self.make_entry_string(&envelope, context, &threads, thread_hash);
|
||||
drop(envelope);
|
||||
|
|
|
@ -131,6 +131,10 @@ impl MailListingTrait for ConversationsListing {
|
|||
&mut self.row_updates
|
||||
}
|
||||
|
||||
fn selection(&mut self) -> &mut HashMap<ThreadHash, bool> {
|
||||
&mut self.selection
|
||||
}
|
||||
|
||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
||||
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
||||
let i = [self.get_thread_under_cursor(self.cursor_pos.2)];
|
||||
|
|
|
@ -26,6 +26,7 @@ use crate::components::utilities::PageMovement;
|
|||
pub struct OfflineListing {
|
||||
cursor_pos: (usize, MailboxHash),
|
||||
_row_updates: SmallVec<[ThreadHash; 8]>,
|
||||
_selection: HashMap<ThreadHash, bool>,
|
||||
dirty: bool,
|
||||
id: ComponentId,
|
||||
}
|
||||
|
@ -35,6 +36,10 @@ impl MailListingTrait for OfflineListing {
|
|||
&mut self._row_updates
|
||||
}
|
||||
|
||||
fn selection(&mut self) -> &mut HashMap<ThreadHash, bool> {
|
||||
&mut self._selection
|
||||
}
|
||||
|
||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
||||
return SmallVec::new();
|
||||
}
|
||||
|
@ -88,6 +93,7 @@ impl OfflineListing {
|
|||
OfflineListing {
|
||||
cursor_pos,
|
||||
_row_updates: SmallVec::new(),
|
||||
_selection: HashMap::default(),
|
||||
dirty: true,
|
||||
id: ComponentId::new_v4(),
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ pub struct PlainListing {
|
|||
filtered_selection: Vec<EnvelopeHash>,
|
||||
filtered_order: HashMap<EnvelopeHash, usize>,
|
||||
selection: HashMap<EnvelopeHash, bool>,
|
||||
_selection: HashMap<ThreadHash, bool>,
|
||||
thread_node_hashes: HashMap<EnvelopeHash, ThreadNodeHash>,
|
||||
local_collection: Vec<EnvelopeHash>,
|
||||
/// If we must redraw on next redraw event
|
||||
|
@ -88,6 +89,10 @@ impl MailListingTrait for PlainListing {
|
|||
&mut self._row_updates
|
||||
}
|
||||
|
||||
fn selection(&mut self) -> &mut HashMap<ThreadHash, bool> {
|
||||
&mut self._selection
|
||||
}
|
||||
|
||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
||||
SmallVec::new()
|
||||
/*
|
||||
|
@ -707,6 +712,7 @@ impl PlainListing {
|
|||
filtered_selection: Vec::new(),
|
||||
filtered_order: HashMap::default(),
|
||||
selection: HashMap::default(),
|
||||
_selection: HashMap::default(),
|
||||
row_updates: SmallVec::new(),
|
||||
_row_updates: SmallVec::new(),
|
||||
data_columns: DataColumns::default(),
|
||||
|
|
|
@ -41,6 +41,7 @@ pub struct ThreadListing {
|
|||
rows_drawn: SegmentTree,
|
||||
rows: Vec<((usize, bool, bool, EnvelopeHash), EntryStrings)>,
|
||||
row_updates: SmallVec<[ThreadHash; 8]>,
|
||||
selection: HashMap<ThreadHash, bool>,
|
||||
order: HashMap<EnvelopeHash, usize>,
|
||||
/// If we must redraw on next redraw event
|
||||
dirty: bool,
|
||||
|
@ -57,6 +58,10 @@ impl MailListingTrait for ThreadListing {
|
|||
&mut self.row_updates
|
||||
}
|
||||
|
||||
fn selection(&mut self) -> &mut HashMap<ThreadHash, bool> {
|
||||
&mut self.selection
|
||||
}
|
||||
|
||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
||||
SmallVec::new()
|
||||
}
|
||||
|
@ -673,6 +678,7 @@ impl ThreadListing {
|
|||
rows_drawn: SegmentTree::default(),
|
||||
rows: vec![],
|
||||
row_updates: SmallVec::new(),
|
||||
selection: HashMap::default(),
|
||||
order: HashMap::default(),
|
||||
dirty: true,
|
||||
unfocused: false,
|
||||
|
|
Loading…
Reference in New Issue