melib: add ThreadGroup
Instead of using Union/Find to gather mail that belongs in the same e-mail thread together, add a new entity ThreadGroup that ThreadNodes point to. ThreadGroup represents an actual Thread: A thread root ThreadGroup::Group or a reply ThreadGroup::Node. To make semantics more accurate: - ThreadNode hash should be renamed to ThreadNodeHash - ThreadGroupHash should be renamed to ThreadHash - ThreadGroup::Group should be a struct named Thread instead - move ThreadGroup::Node logic to ThreadNode akin to Union/Find - rename ThreaddGroup::Group to Threadasync
parent
20f86f2741
commit
47a69f8eb9
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,209 @@
|
||||||
|
/*
|
||||||
|
* meli - melib
|
||||||
|
*
|
||||||
|
* Copyright Manos Pitsidianakis
|
||||||
|
*
|
||||||
|
* This file is part of meli.
|
||||||
|
*
|
||||||
|
* meli is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* meli is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use super::{ThreadGroup, ThreadHash, ThreadNode};
|
||||||
|
use fnv::FnvHashMap;
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
use std::cell::Ref;
|
||||||
|
|
||||||
|
/* `ThreadsIterator` returns messages according to the sorted order. For example, for the following
|
||||||
|
* threads:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* A_
|
||||||
|
* |_ B
|
||||||
|
* |_C
|
||||||
|
* D
|
||||||
|
* E_
|
||||||
|
* |_F
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* the iterator returns them as `A, B, C, D, E, F`
|
||||||
|
*/
|
||||||
|
|
||||||
|
pub struct ThreadsIterator<'a> {
|
||||||
|
pub(super) pos: usize,
|
||||||
|
pub(super) stack: SmallVec<[usize; 16]>,
|
||||||
|
pub(super) root_tree: Ref<'a, Vec<ThreadHash>>,
|
||||||
|
pub(super) thread_nodes: &'a FnvHashMap<ThreadHash, ThreadNode>,
|
||||||
|
}
|
||||||
|
impl<'a> Iterator for ThreadsIterator<'a> {
|
||||||
|
type Item = (usize, ThreadHash, bool);
|
||||||
|
fn next(&mut self) -> Option<(usize, ThreadHash, bool)> {
|
||||||
|
{
|
||||||
|
let mut tree = &(*self.root_tree);
|
||||||
|
for i in self.stack.iter() {
|
||||||
|
tree = &self.thread_nodes[&tree[*i]].children;
|
||||||
|
}
|
||||||
|
if self.pos == tree.len() {
|
||||||
|
if let Some(p) = self.stack.pop() {
|
||||||
|
self.pos = p + 1;
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug_assert!(self.pos < tree.len());
|
||||||
|
let ret = (
|
||||||
|
self.stack.len(),
|
||||||
|
tree[self.pos],
|
||||||
|
!self.stack.is_empty() && (self.pos < (tree.len() - 1)),
|
||||||
|
);
|
||||||
|
if !self.thread_nodes[&tree[self.pos]].children.is_empty() {
|
||||||
|
self.stack.push(self.pos);
|
||||||
|
self.pos = 0;
|
||||||
|
if self.thread_nodes[&ret.1].message.is_some() {
|
||||||
|
return Some(ret);
|
||||||
|
} else {
|
||||||
|
return self.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.pos += 1;
|
||||||
|
if self.thread_nodes[&ret.1].message.is_some() {
|
||||||
|
return Some(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* `ThreadIterator` returns messages of a specific thread according to the sorted order. For example, for the following
|
||||||
|
* thread:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* A_
|
||||||
|
* |_ B
|
||||||
|
* |_C
|
||||||
|
* |_D
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* the iterator returns them as `A, B, C, D`
|
||||||
|
*/
|
||||||
|
|
||||||
|
pub struct ThreadIterator<'a> {
|
||||||
|
pub(super) init_pos: usize,
|
||||||
|
pub(super) pos: usize,
|
||||||
|
pub(super) stack: SmallVec<[usize; 16]>,
|
||||||
|
pub(super) root_tree: Ref<'a, Vec<ThreadHash>>,
|
||||||
|
pub(super) thread_nodes: &'a FnvHashMap<ThreadHash, ThreadNode>,
|
||||||
|
}
|
||||||
|
impl<'a> Iterator for ThreadIterator<'a> {
|
||||||
|
type Item = (usize, ThreadHash);
|
||||||
|
fn next(&mut self) -> Option<(usize, ThreadHash)> {
|
||||||
|
{
|
||||||
|
let mut tree = &(*self.root_tree);
|
||||||
|
for i in self.stack.iter() {
|
||||||
|
tree = &self.thread_nodes[&tree[*i]].children;
|
||||||
|
}
|
||||||
|
if self.pos == tree.len() || (self.stack.is_empty() && self.pos > self.init_pos) {
|
||||||
|
if self.stack.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
self.pos = self.stack.pop().unwrap() + 1;
|
||||||
|
} else {
|
||||||
|
debug_assert!(self.pos < tree.len());
|
||||||
|
let ret = (self.stack.len(), tree[self.pos]);
|
||||||
|
if !self.thread_nodes[&tree[self.pos]].children.is_empty() {
|
||||||
|
self.stack.push(self.pos);
|
||||||
|
self.pos = 0;
|
||||||
|
if self.thread_nodes[&ret.1].message.is_some() {
|
||||||
|
return Some(ret);
|
||||||
|
} else {
|
||||||
|
return self.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.pos += 1;
|
||||||
|
if self.thread_nodes[&ret.1].message.is_some() {
|
||||||
|
return Some(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct RootIterator<'a> {
|
||||||
|
pub pos: usize,
|
||||||
|
pub root_tree: Ref<'a, Vec<ThreadHash>>,
|
||||||
|
pub thread_nodes: &'a FnvHashMap<ThreadHash, ThreadNode>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Iterator for RootIterator<'a> {
|
||||||
|
type Item = ThreadHash;
|
||||||
|
fn next(&mut self) -> Option<ThreadHash> {
|
||||||
|
{
|
||||||
|
if self.pos == self.root_tree.len() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let mut ret = self.root_tree[self.pos];
|
||||||
|
self.pos += 1;
|
||||||
|
let thread_node = &self.thread_nodes[&ret];
|
||||||
|
if thread_node.message().is_none() {
|
||||||
|
ret = thread_node.children()[0];
|
||||||
|
while self.thread_nodes[&ret].message().is_none() {
|
||||||
|
ret = self.thread_nodes[&ret].children()[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(ret)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ThreadGroupIterator<'a> {
|
||||||
|
pub(super) group: ThreadHash,
|
||||||
|
pub(super) pos: usize,
|
||||||
|
pub(super) stack: SmallVec<[usize; 16]>,
|
||||||
|
pub(super) thread_nodes: &'a FnvHashMap<ThreadHash, ThreadNode>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Iterator for ThreadGroupIterator<'a> {
|
||||||
|
type Item = (usize, ThreadHash);
|
||||||
|
fn next(&mut self) -> Option<(usize, ThreadHash)> {
|
||||||
|
{
|
||||||
|
let mut tree = &[self.group][..];
|
||||||
|
for i in self.stack.iter() {
|
||||||
|
tree = self.thread_nodes[&tree[*i]].children.as_slice();
|
||||||
|
}
|
||||||
|
if self.pos == tree.len() {
|
||||||
|
if self.stack.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
self.pos = self.stack.pop().unwrap() + 1;
|
||||||
|
} else {
|
||||||
|
debug_assert!(self.pos < tree.len());
|
||||||
|
let ret = (self.stack.len(), tree[self.pos]);
|
||||||
|
if !self.thread_nodes[&tree[self.pos]].children.is_empty() {
|
||||||
|
self.stack.push(self.pos);
|
||||||
|
self.pos = 0;
|
||||||
|
if self.thread_nodes[&ret.1].message.is_some() {
|
||||||
|
return Some(ret);
|
||||||
|
} else {
|
||||||
|
return self.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.pos += 1;
|
||||||
|
if self.thread_nodes[&ret.1].message.is_some() {
|
||||||
|
return Some(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.next()
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,7 +63,7 @@ impl std::ops::DerefMut for EmbedStatus {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Composer {
|
pub struct Composer {
|
||||||
reply_context: Option<(usize, usize)>, // (folder_index, thread_node_index)
|
reply_context: Option<(FolderHash, EnvelopeHash)>,
|
||||||
account_cursor: usize,
|
account_cursor: usize,
|
||||||
|
|
||||||
cursor: Cursor,
|
cursor: Cursor,
|
||||||
|
@ -148,11 +148,7 @@ impl Composer {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* coordinates: (account index, mailbox index, root set thread_node index)
|
|
||||||
* msg: index of message we reply to in thread_nodes
|
|
||||||
* context: current context
|
|
||||||
*/
|
|
||||||
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Result<Self> {
|
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Result<Self> {
|
||||||
let mut ret = Composer::default();
|
let mut ret = Composer::default();
|
||||||
let op = context.accounts[account_pos].operation(h);
|
let op = context.accounts[account_pos].operation(h);
|
||||||
|
@ -163,18 +159,15 @@ impl Composer {
|
||||||
ret.account_cursor = account_pos;
|
ret.account_cursor = account_pos;
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_context(
|
pub fn with_context(
|
||||||
coordinates: (usize, usize, usize),
|
coordinates: (usize, FolderHash),
|
||||||
msg: ThreadHash,
|
msg: EnvelopeHash,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let account = &context.accounts[coordinates.0];
|
let account = &context.accounts[coordinates.0];
|
||||||
let mailbox = &account[coordinates.1].unwrap();
|
|
||||||
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
|
||||||
let thread_nodes = &threads.thread_nodes();
|
|
||||||
let mut ret = Composer::default();
|
let mut ret = Composer::default();
|
||||||
let p = &thread_nodes[&msg];
|
let parent_message = account.collection.get_env(msg);
|
||||||
let parent_message = account.collection.get_env(p.message().unwrap());
|
|
||||||
/* If message is from a mailing list and we detect a List-Post header, ask user if they
|
/* If message is from a mailing list and we detect a List-Post header, ask user if they
|
||||||
* want to reply to the mailing list or the submitter of the message */
|
* want to reply to the mailing list or the submitter of the message */
|
||||||
if let Some(actions) = list_management::ListActions::detect(&parent_message) {
|
if let Some(actions) = list_management::ListActions::detect(&parent_message) {
|
||||||
|
@ -202,32 +195,22 @@ impl Composer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut op = account.operation(parent_message.hash());
|
let mut op = account.operation(msg);
|
||||||
let parent_bytes = op.as_bytes();
|
let parent_bytes = op.as_bytes();
|
||||||
|
|
||||||
ret.draft = Draft::new_reply(&parent_message, parent_bytes.unwrap());
|
ret.draft = Draft::new_reply(&parent_message, parent_bytes.unwrap());
|
||||||
|
let subject = parent_message.subject();
|
||||||
ret.draft.headers_mut().insert(
|
ret.draft.headers_mut().insert(
|
||||||
"Subject".into(),
|
"Subject".into(),
|
||||||
if p.show_subject() {
|
if !subject.starts_with("Re: ") {
|
||||||
format!(
|
format!("Re: {}", subject)
|
||||||
"Re: {}",
|
|
||||||
account
|
|
||||||
.collection
|
|
||||||
.get_env(p.message().unwrap())
|
|
||||||
.subject()
|
|
||||||
.clone()
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
account
|
subject.into()
|
||||||
.collection
|
|
||||||
.get_env(p.message().unwrap())
|
|
||||||
.subject()
|
|
||||||
.into()
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
ret.account_cursor = coordinates.0;
|
ret.account_cursor = coordinates.0;
|
||||||
ret.reply_context = Some((coordinates.1, coordinates.2));
|
ret.reply_context = Some((coordinates.1, msg));
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,13 +536,13 @@ impl Component for Composer {
|
||||||
|
|
||||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
||||||
let shortcuts = self.get_shortcuts(context);
|
let shortcuts = self.get_shortcuts(context);
|
||||||
match (&mut self.mode, &mut self.reply_context, &event) {
|
match (&mut self.mode, &event) {
|
||||||
(ViewMode::Edit, _, _) => {
|
(ViewMode::Edit, _) => {
|
||||||
if self.pager.process_event(event, context) {
|
if self.pager.process_event(event, context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(ViewMode::Send(ref mut selector), _, _) => {
|
(ViewMode::Send(ref mut selector), _) => {
|
||||||
if selector.process_event(event, context) {
|
if selector.process_event(event, context) {
|
||||||
if selector.is_done() {
|
if selector.is_done() {
|
||||||
let s = match std::mem::replace(&mut self.mode, ViewMode::Edit) {
|
let s = match std::mem::replace(&mut self.mode, ViewMode::Edit) {
|
||||||
|
@ -594,7 +577,7 @@ impl Component for Composer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(ViewMode::SelectRecipients(ref mut selector), _, _) => {
|
(ViewMode::SelectRecipients(ref mut selector), _) => {
|
||||||
if selector.process_event(event, context) {
|
if selector.process_event(event, context) {
|
||||||
if selector.is_done() {
|
if selector.is_done() {
|
||||||
let s = match std::mem::replace(&mut self.mode, ViewMode::Edit) {
|
let s = match std::mem::replace(&mut self.mode, ViewMode::Edit) {
|
||||||
|
@ -615,7 +598,7 @@ impl Component for Composer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(ViewMode::Discard(_, ref mut selector), _, _) => {
|
(ViewMode::Discard(_, ref mut selector), _) => {
|
||||||
if selector.process_event(event, context) {
|
if selector.process_event(event, context) {
|
||||||
if selector.is_done() {
|
if selector.is_done() {
|
||||||
let (u, s) = match std::mem::replace(&mut self.mode, ViewMode::Edit) {
|
let (u, s) = match std::mem::replace(&mut self.mode, ViewMode::Edit) {
|
||||||
|
|
|
@ -53,37 +53,18 @@ pub trait MailListingTrait: ListingTrait {
|
||||||
fn perform_action(
|
fn perform_action(
|
||||||
&mut self,
|
&mut self,
|
||||||
context: &mut Context,
|
context: &mut Context,
|
||||||
thread_hash: ThreadHash,
|
thread_hash: ThreadGroupHash,
|
||||||
a: &ListingAction,
|
a: &ListingAction,
|
||||||
) {
|
) {
|
||||||
let account = &mut context.accounts[self.coordinates().0];
|
let account = &mut context.accounts[self.coordinates().0];
|
||||||
let mut envs_to_set: SmallVec<[EnvelopeHash; 8]> = SmallVec::new();
|
let mut envs_to_set: SmallVec<[EnvelopeHash; 8]> = SmallVec::new();
|
||||||
let folder_hash = account[self.coordinates().1].unwrap().folder.hash();
|
let folder_hash = account[self.coordinates().1].unwrap().folder.hash();
|
||||||
{
|
for (_, h) in account.collection.threads[&folder_hash].thread_group_iter(thread_hash) {
|
||||||
let mut stack: SmallVec<[ThreadHash; 8]> = SmallVec::new();
|
envs_to_set.push(
|
||||||
stack.push(thread_hash);
|
account.collection.threads[&folder_hash].thread_nodes()[&h]
|
||||||
while let Some(thread_iter) = stack.pop() {
|
.message()
|
||||||
{
|
.unwrap(),
|
||||||
let threads = account.collection.threads.get_mut(&folder_hash).unwrap();
|
);
|
||||||
threads
|
|
||||||
.thread_nodes
|
|
||||||
.entry(thread_iter)
|
|
||||||
.and_modify(|t| t.set_has_unseen(false));
|
|
||||||
}
|
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
if let Some(env_hash) = threads[&thread_iter].message() {
|
|
||||||
if !account.contains_key(env_hash) {
|
|
||||||
/* The envelope has been renamed or removed, so wait for the appropriate event to
|
|
||||||
* arrive */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
envs_to_set.push(env_hash);
|
|
||||||
}
|
|
||||||
for c in 0..threads[&thread_iter].children().len() {
|
|
||||||
let c = threads[&thread_iter].children()[c];
|
|
||||||
stack.push(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for env_hash in envs_to_set {
|
for env_hash in envs_to_set {
|
||||||
let op = account.operation(env_hash);
|
let op = account.operation(env_hash);
|
||||||
|
@ -139,9 +120,9 @@ pub trait MailListingTrait: ListingTrait {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]>;
|
fn row_updates(&mut self) -> &mut SmallVec<[ThreadGroupHash; 8]>;
|
||||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]>;
|
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadGroupHash; 8]>;
|
||||||
fn redraw_list(&mut self, context: &Context, items: Box<dyn Iterator<Item = ThreadHash>>) {
|
fn redraw_list(&mut self, context: &Context, items: Box<dyn Iterator<Item = ThreadGroupHash>>) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,33 +54,33 @@ pub struct CompactListing {
|
||||||
length: usize,
|
length: usize,
|
||||||
sort: (SortField, SortOrder),
|
sort: (SortField, SortOrder),
|
||||||
subsort: (SortField, SortOrder),
|
subsort: (SortField, SortOrder),
|
||||||
all_threads: fnv::FnvHashSet<ThreadHash>,
|
all_threads: fnv::FnvHashSet<ThreadGroupHash>,
|
||||||
order: FnvHashMap<ThreadHash, usize>,
|
order: FnvHashMap<ThreadGroupHash, usize>,
|
||||||
/// Cache current view.
|
/// Cache current view.
|
||||||
data_columns: DataColumns,
|
data_columns: DataColumns,
|
||||||
|
|
||||||
filter_term: String,
|
filter_term: String,
|
||||||
filtered_selection: Vec<ThreadHash>,
|
filtered_selection: Vec<ThreadGroupHash>,
|
||||||
filtered_order: FnvHashMap<ThreadHash, usize>,
|
filtered_order: FnvHashMap<ThreadGroupHash, usize>,
|
||||||
selection: FnvHashMap<ThreadHash, bool>,
|
selection: FnvHashMap<ThreadGroupHash, bool>,
|
||||||
/// If we must redraw on next redraw event
|
/// If we must redraw on next redraw event
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
force_draw: bool,
|
force_draw: bool,
|
||||||
/// If `self.view` exists or not.
|
/// If `self.view` exists or not.
|
||||||
unfocused: bool,
|
unfocused: bool,
|
||||||
view: ThreadView,
|
view: ThreadView,
|
||||||
row_updates: SmallVec<[ThreadHash; 8]>,
|
row_updates: SmallVec<[ThreadGroupHash; 8]>,
|
||||||
|
|
||||||
movement: Option<PageMovement>,
|
movement: Option<PageMovement>,
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MailListingTrait for CompactListing {
|
impl MailListingTrait for CompactListing {
|
||||||
fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]> {
|
fn row_updates(&mut self) -> &mut SmallVec<[ThreadGroupHash; 8]> {
|
||||||
&mut self.row_updates
|
&mut self.row_updates
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadGroupHash; 8]> {
|
||||||
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
||||||
let i = [self.get_thread_under_cursor(self.cursor_pos.2, context)];
|
let i = [self.get_thread_under_cursor(self.cursor_pos.2, context)];
|
||||||
let cursor_iter;
|
let cursor_iter;
|
||||||
|
@ -118,14 +118,13 @@ impl ListingTrait for CompactListing {
|
||||||
if self.length == 0 {
|
if self.length == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let i = self.get_thread_under_cursor(idx, context);
|
let thread = self.get_thread_under_cursor(idx, context);
|
||||||
|
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
let account = &context.accounts[self.cursor_pos.0];
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
let threads = &account.collection.threads[&folder_hash];
|
||||||
let thread_node = &threads.thread_nodes[&i];
|
|
||||||
|
|
||||||
let fg_color = if thread_node.has_unseen() {
|
let fg_color = if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
@ -133,9 +132,9 @@ impl ListingTrait for CompactListing {
|
||||||
let bg_color = if context.settings.terminal.theme == "light" {
|
let bg_color = if context.settings.terminal.theme == "light" {
|
||||||
if self.cursor_pos.2 == idx {
|
if self.cursor_pos.2 == idx {
|
||||||
Color::Byte(244)
|
Color::Byte(244)
|
||||||
} else if self.selection[&i] {
|
} else if self.selection[&thread] {
|
||||||
Color::Byte(210)
|
Color::Byte(210)
|
||||||
} else if thread_node.has_unseen() {
|
} else if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
Color::Byte(252)
|
Color::Byte(252)
|
||||||
|
@ -145,9 +144,9 @@ impl ListingTrait for CompactListing {
|
||||||
} else {
|
} else {
|
||||||
if self.cursor_pos.2 == idx {
|
if self.cursor_pos.2 == idx {
|
||||||
Color::Byte(246)
|
Color::Byte(246)
|
||||||
} else if self.selection[&i] {
|
} else if self.selection[&thread] {
|
||||||
Color::Byte(210)
|
Color::Byte(210)
|
||||||
} else if thread_node.has_unseen() {
|
} else if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
Color::Byte(236)
|
Color::Byte(236)
|
||||||
|
@ -444,21 +443,19 @@ impl ListingTrait for CompactListing {
|
||||||
if !threads.thread_nodes.contains_key(&env_hash_thread_hash) {
|
if !threads.thread_nodes.contains_key(&env_hash_thread_hash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let thread_group = melib::find_root_hash(
|
let thread =
|
||||||
&threads.thread_nodes,
|
threads.find_group(threads.thread_nodes[&env_hash_thread_hash].group);
|
||||||
threads.thread_nodes[&env_hash_thread_hash].thread_group(),
|
if self.filtered_order.contains_key(&thread) {
|
||||||
);
|
|
||||||
if self.filtered_order.contains_key(&thread_group) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if self.all_threads.contains(&thread_group) {
|
if self.all_threads.contains(&thread) {
|
||||||
self.filtered_selection.push(thread_group);
|
self.filtered_selection.push(thread);
|
||||||
self.filtered_order
|
self.filtered_order
|
||||||
.insert(thread_group, self.filtered_selection.len() - 1);
|
.insert(thread, self.filtered_selection.len() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !self.filtered_selection.is_empty() {
|
if !self.filtered_selection.is_empty() {
|
||||||
threads.vec_inner_sort_by(
|
threads.group_inner_sort_by(
|
||||||
&mut self.filtered_selection,
|
&mut self.filtered_selection,
|
||||||
self.sort,
|
self.sort,
|
||||||
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
||||||
|
@ -472,7 +469,7 @@ impl ListingTrait for CompactListing {
|
||||||
self.redraw_list(
|
self.redraw_list(
|
||||||
context,
|
context,
|
||||||
Box::new(self.filtered_selection.clone().into_iter())
|
Box::new(self.filtered_selection.clone().into_iter())
|
||||||
as Box<dyn Iterator<Item = ThreadHash>>,
|
as Box<dyn Iterator<Item = ThreadGroupHash>>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -550,12 +547,9 @@ impl CompactListing {
|
||||||
e: &Envelope,
|
e: &Envelope,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
threads: &Threads,
|
threads: &Threads,
|
||||||
hash: ThreadHash,
|
hash: ThreadGroupHash,
|
||||||
) -> EntryStrings {
|
) -> EntryStrings {
|
||||||
let is_snoozed: bool = threads.is_snoozed(hash);
|
let thread = &threads.groups[&hash];
|
||||||
let date =
|
|
||||||
threads.thread_dates[&melib::thread::find_thread_group(threads.thread_nodes(), hash)];
|
|
||||||
let thread_node = &threads[&hash];
|
|
||||||
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.folder
|
.folder
|
||||||
|
@ -597,26 +591,26 @@ impl CompactListing {
|
||||||
}
|
}
|
||||||
let mut subject = e.subject().to_string();
|
let mut subject = e.subject().to_string();
|
||||||
subject.truncate_at_boundary(150);
|
subject.truncate_at_boundary(150);
|
||||||
if thread_node.len() > 0 {
|
if thread.len() > 1 {
|
||||||
EntryStrings {
|
EntryStrings {
|
||||||
date: DateString(ConversationsListing::format_date(context, date)),
|
date: DateString(ConversationsListing::format_date(context, thread.date())),
|
||||||
subject: SubjectString(format!("{} ({})", subject, thread_node.len(),)),
|
subject: SubjectString(format!("{} ({})", subject, thread.len(),)),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "📎" } else { "" },
|
if e.has_attachments() { "📎" } else { "" },
|
||||||
if is_snoozed { "💤" } else { "" }
|
if thread.snoozed() { "💤" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
||||||
tags: TagString(tags, colors),
|
tags: TagString(tags, colors),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EntryStrings {
|
EntryStrings {
|
||||||
date: DateString(ConversationsListing::format_date(context, date)),
|
date: DateString(ConversationsListing::format_date(context, thread.date())),
|
||||||
subject: SubjectString(subject),
|
subject: SubjectString(subject),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "📎" } else { "" },
|
if e.has_attachments() { "📎" } else { "" },
|
||||||
if is_snoozed { "💤" } else { "" }
|
if thread.snoozed() { "💤" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
||||||
tags: TagString(tags, colors),
|
tags: TagString(tags, colors),
|
||||||
|
@ -669,28 +663,31 @@ impl CompactListing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if old_cursor_pos == self.new_cursor_pos {
|
|
||||||
self.view.update(context);
|
|
||||||
} else if self.unfocused {
|
|
||||||
self.view = ThreadView::new(self.new_cursor_pos, None, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&folder_hash];
|
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&folder_hash];
|
||||||
threads.sort_by(
|
self.all_threads.clear();
|
||||||
|
let mut roots = threads.roots();
|
||||||
|
threads.group_inner_sort_by(
|
||||||
|
&mut roots,
|
||||||
self.sort,
|
self.sort,
|
||||||
self.subsort,
|
|
||||||
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
||||||
);
|
);
|
||||||
self.all_threads.clear();
|
|
||||||
|
|
||||||
self.redraw_list(
|
self.redraw_list(
|
||||||
context,
|
context,
|
||||||
Box::new(threads.root_iter().collect::<Vec<ThreadHash>>().into_iter())
|
Box::new(roots.into_iter()) as Box<dyn Iterator<Item = ThreadGroupHash>>,
|
||||||
as Box<dyn Iterator<Item = ThreadHash>>,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if old_cursor_pos == self.new_cursor_pos {
|
||||||
|
self.view.update(context);
|
||||||
|
} else if self.unfocused {
|
||||||
|
let thread = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
|
|
||||||
|
self.view = ThreadView::new(self.new_cursor_pos, thread, None, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn redraw_list(&mut self, context: &Context, items: Box<dyn Iterator<Item = ThreadHash>>) {
|
fn redraw_list(&mut self, context: &Context, items: Box<dyn Iterator<Item = ThreadGroupHash>>) {
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
let account = &context.accounts[self.cursor_pos.0];
|
||||||
let mailbox = &account[self.cursor_pos.1].unwrap();
|
let mailbox = &account[self.cursor_pos.1].unwrap();
|
||||||
|
|
||||||
|
@ -714,18 +711,19 @@ impl CompactListing {
|
||||||
SmallVec::new(),
|
SmallVec::new(),
|
||||||
);
|
);
|
||||||
|
|
||||||
for (idx, root_idx) in items.enumerate() {
|
for (idx, thread) in items.enumerate() {
|
||||||
|
debug!(thread);
|
||||||
self.length += 1;
|
self.length += 1;
|
||||||
let thread_node = &threads.thread_nodes()[&root_idx];
|
let thread_node = &threads.thread_nodes()[&threads.groups[&thread].root().unwrap()];
|
||||||
let i = thread_node.message().unwrap_or_else(|| {
|
let root_env_hash = thread_node.message().unwrap_or_else(|| {
|
||||||
let mut iter_ptr = thread_node.children()[0];
|
let mut iter_ptr = thread_node.children()[0];
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||||
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
||||||
}
|
}
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||||
});
|
});
|
||||||
if !context.accounts[self.cursor_pos.0].contains_key(i) {
|
if !context.accounts[self.cursor_pos.0].contains_key(root_env_hash) {
|
||||||
debug!("key = {}", i);
|
debug!("key = {}", root_env_hash);
|
||||||
debug!(
|
debug!(
|
||||||
"name = {} {}",
|
"name = {} {}",
|
||||||
mailbox.name(),
|
mailbox.name(),
|
||||||
|
@ -735,10 +733,11 @@ impl CompactListing {
|
||||||
|
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
let root_envelope: EnvelopeRef =
|
let root_envelope: EnvelopeRef = context.accounts[self.cursor_pos.0]
|
||||||
context.accounts[self.cursor_pos.0].collection.get_env(i);
|
.collection
|
||||||
|
.get_env(root_env_hash);
|
||||||
|
|
||||||
let entry_strings = self.make_entry_string(&root_envelope, context, threads, root_idx);
|
let entry_strings = self.make_entry_string(&root_envelope, context, threads, thread);
|
||||||
row_widths.1.push(
|
row_widths.1.push(
|
||||||
entry_strings
|
entry_strings
|
||||||
.date
|
.date
|
||||||
|
@ -772,11 +771,11 @@ impl CompactListing {
|
||||||
min_width.4,
|
min_width.4,
|
||||||
entry_strings.subject.grapheme_width() + 1 + entry_strings.tags.grapheme_width(),
|
entry_strings.subject.grapheme_width() + 1 + entry_strings.tags.grapheme_width(),
|
||||||
); /* subject */
|
); /* subject */
|
||||||
rows.push(((idx, root_idx), entry_strings));
|
rows.push(((idx, (thread, root_env_hash)), entry_strings));
|
||||||
self.all_threads.insert(root_idx);
|
self.all_threads.insert(thread);
|
||||||
|
|
||||||
self.order.insert(root_idx, idx);
|
self.order.insert(thread, idx);
|
||||||
self.selection.insert(root_idx, false);
|
self.selection.insert(thread, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
min_width.0 = self.length.saturating_sub(1).to_string().len();
|
min_width.0 = self.length.saturating_sub(1).to_string().len();
|
||||||
|
@ -800,17 +799,9 @@ impl CompactListing {
|
||||||
CellBuffer::new_with_context(min_width.4, rows.len(), Cell::with_char(' '), context);
|
CellBuffer::new_with_context(min_width.4, rows.len(), Cell::with_char(' '), context);
|
||||||
self.data_columns.segment_tree[4] = row_widths.4.into();
|
self.data_columns.segment_tree[4] = row_widths.4.into();
|
||||||
|
|
||||||
for ((idx, root_idx), strings) in rows {
|
for ((idx, (thread, root_env_hash)), strings) in rows {
|
||||||
let thread_node = &threads.thread_nodes()[&root_idx];
|
if !context.accounts[self.cursor_pos.0].contains_key(root_env_hash) {
|
||||||
let i = thread_node.message().unwrap_or_else(|| {
|
//debug!("key = {}", root_env_hash);
|
||||||
let mut iter_ptr = thread_node.children()[0];
|
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
|
||||||
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
|
||||||
}
|
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
|
||||||
});
|
|
||||||
if !context.accounts[self.cursor_pos.0].contains_key(i) {
|
|
||||||
//debug!("key = {}", i);
|
|
||||||
//debug!(
|
//debug!(
|
||||||
// "name = {} {}",
|
// "name = {} {}",
|
||||||
// mailbox.name(),
|
// mailbox.name(),
|
||||||
|
@ -820,13 +811,13 @@ impl CompactListing {
|
||||||
|
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
let fg_color = if thread_node.has_unseen() {
|
let fg_color = if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
};
|
};
|
||||||
let bg_color = if context.settings.terminal.theme == "light" {
|
let bg_color = if context.settings.terminal.theme == "light" {
|
||||||
if thread_node.has_unseen() {
|
if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
Color::Byte(252)
|
Color::Byte(252)
|
||||||
|
@ -834,7 +825,7 @@ impl CompactListing {
|
||||||
Color::Default
|
Color::Default
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if thread_node.has_unseen() {
|
if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
Color::Byte(236)
|
Color::Byte(236)
|
||||||
|
@ -930,10 +921,10 @@ impl CompactListing {
|
||||||
self.data_columns.columns[4][(x, idx)].set_bg(bg_color);
|
self.data_columns.columns[4][(x, idx)].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
match (
|
match (
|
||||||
threads.is_snoozed(root_idx),
|
threads.groups[&thread].snoozed(),
|
||||||
context.accounts[self.cursor_pos.0]
|
context.accounts[self.cursor_pos.0]
|
||||||
.collection
|
.collection
|
||||||
.get_env(i)
|
.get_env(root_env_hash)
|
||||||
.has_attachments(),
|
.has_attachments(),
|
||||||
) {
|
) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
|
@ -970,7 +961,7 @@ impl CompactListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash {
|
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadGroupHash {
|
||||||
//let account = &context.accounts[self.cursor_pos.0];
|
//let account = &context.accounts[self.cursor_pos.0];
|
||||||
//let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
//let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
if self.filter_term.is_empty() {
|
if self.filter_term.is_empty() {
|
||||||
|
@ -983,17 +974,18 @@ impl CompactListing {
|
||||||
panic!();
|
panic!();
|
||||||
})
|
})
|
||||||
.0
|
.0
|
||||||
//threads.root_set(cursor)
|
|
||||||
} else {
|
} else {
|
||||||
self.filtered_selection[cursor]
|
self.filtered_selection[cursor]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) {
|
fn update_line(&mut self, context: &Context, thread_hash: ThreadGroupHash) {
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
let account = &context.accounts[self.cursor_pos.0];
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
let threads = &account.collection.threads[&folder_hash];
|
||||||
if let Some(env_hash) = threads[&thread_hash].message() {
|
if let Some(env_hash) =
|
||||||
|
threads.thread_nodes()[&threads.groups[&thread_hash].root().unwrap()].message()
|
||||||
|
{
|
||||||
if !account.contains_key(env_hash) {
|
if !account.contains_key(env_hash) {
|
||||||
/* The envelope has been renamed or removed, so wait for the appropriate event to
|
/* The envelope has been renamed or removed, so wait for the appropriate event to
|
||||||
* arrive */
|
* arrive */
|
||||||
|
@ -1001,14 +993,14 @@ impl CompactListing {
|
||||||
}
|
}
|
||||||
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
||||||
let has_attachments = envelope.has_attachments();
|
let has_attachments = envelope.has_attachments();
|
||||||
let fg_color = if threads[&thread_hash].has_unseen() {
|
let fg_color = if threads.groups[&thread_hash].unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
};
|
};
|
||||||
let idx = self.order[&thread_hash];
|
let idx = self.order[&thread_hash];
|
||||||
let bg_color = if context.settings.terminal.theme == "light" {
|
let bg_color = if context.settings.terminal.theme == "light" {
|
||||||
if threads[&thread_hash].has_unseen() {
|
if threads.groups[&thread_hash].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
Color::Byte(252)
|
Color::Byte(252)
|
||||||
|
@ -1016,7 +1008,7 @@ impl CompactListing {
|
||||||
Color::Default
|
Color::Default
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if threads[&thread_hash].has_unseen() {
|
if threads.groups[&thread_hash].unseen() > 0 {
|
||||||
Color::Byte(253)
|
Color::Byte(253)
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
Color::Byte(236)
|
Color::Byte(236)
|
||||||
|
@ -1125,7 +1117,7 @@ impl CompactListing {
|
||||||
columns[4][c].set_ch(' ');
|
columns[4][c].set_ch(' ');
|
||||||
columns[4][c].set_bg(bg_color);
|
columns[4][c].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
match (threads.is_snoozed(thread_hash), has_attachments) {
|
match (threads.groups[&thread_hash].snoozed(), has_attachments) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
columns[3][(0, idx)].set_fg(Color::Byte(103));
|
columns[3][(0, idx)].set_fg(Color::Byte(103));
|
||||||
columns[3][(2, idx)].set_fg(Color::Red);
|
columns[3][(2, idx)].set_fg(Color::Red);
|
||||||
|
@ -1225,22 +1217,8 @@ impl Component for CompactListing {
|
||||||
k == shortcuts[CompactListing::DESCRIPTION]["open_thread"]
|
k == shortcuts[CompactListing::DESCRIPTION]["open_thread"]
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
if self.filtered_selection.is_empty() {
|
let thread = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
self.view = ThreadView::new(self.cursor_pos, None, context);
|
self.view = ThreadView::new(self.cursor_pos, thread, None, context);
|
||||||
} else {
|
|
||||||
let mut temp = self.cursor_pos;
|
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let root_thread_index = threads.root_iter().position(|t| t == thread_hash);
|
|
||||||
if let Some(pos) = root_thread_index {
|
|
||||||
temp.2 = pos;
|
|
||||||
self.view = ThreadView::new(temp, Some(thread_hash), context);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.unfocused = true;
|
self.unfocused = true;
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1269,48 +1247,34 @@ impl Component for CompactListing {
|
||||||
self.selection.entry(thread_hash).and_modify(|e| *e = !*e);
|
self.selection.entry(thread_hash).and_modify(|e| *e = !*e);
|
||||||
}
|
}
|
||||||
UIEvent::Action(ref action) => match action {
|
UIEvent::Action(ref action) => match action {
|
||||||
Action::SubSort(field, order) if !self.unfocused => {
|
|
||||||
debug!("SubSort {:?} , {:?}", field, order);
|
|
||||||
self.subsort = (*field, *order);
|
|
||||||
//if !self.filtered_selection.is_empty() {
|
|
||||||
// let threads = &account.collection.threads[&folder_hash];
|
|
||||||
// threads.vec_inner_sort_by(&mut self.filtered_selection, self.sort, &account.collection);
|
|
||||||
//} else {
|
|
||||||
// self.refresh_mailbox(context);
|
|
||||||
//}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Action::Sort(field, order) if !self.unfocused => {
|
Action::Sort(field, order) if !self.unfocused => {
|
||||||
debug!("Sort {:?} , {:?}", field, order);
|
debug!("Sort {:?} , {:?}", field, order);
|
||||||
self.sort = (*field, *order);
|
self.sort = (*field, *order);
|
||||||
if !self.filtered_selection.is_empty() {
|
if !self.filtered_selection.is_empty() {
|
||||||
let folder_hash = context.accounts[self.cursor_pos.0]
|
// FIXME: perform sort
|
||||||
[self.cursor_pos.1]
|
|
||||||
.unwrap()
|
|
||||||
.folder
|
|
||||||
.hash();
|
|
||||||
let threads = &context.accounts[self.cursor_pos.0].collection.threads
|
|
||||||
[&folder_hash];
|
|
||||||
threads.vec_inner_sort_by(
|
|
||||||
&mut self.filtered_selection,
|
|
||||||
self.sort,
|
|
||||||
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
|
||||||
);
|
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
} else {
|
} else {
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Action::SubSort(field, order) if !self.unfocused => {
|
||||||
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
|
self.subsort = (*field, *order);
|
||||||
|
// FIXME: perform subsort.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Action::ToggleThreadSnooze if !self.unfocused => {
|
Action::ToggleThreadSnooze if !self.unfocused => {
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
let thread = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
let account = &mut context.accounts[self.cursor_pos.0];
|
let account = &mut context.accounts[self.cursor_pos.0];
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
let threads = account.collection.threads.entry(folder_hash).or_default();
|
let threads = account.collection.threads.entry(folder_hash).or_default();
|
||||||
let root_node = threads.thread_nodes.entry(thread_hash).or_default();
|
let is_snoozed = threads.groups[&thread].snoozed();
|
||||||
let is_snoozed = root_node.snoozed();
|
threads
|
||||||
root_node.set_snoozed(!is_snoozed);
|
.groups
|
||||||
self.row_updates.push(thread_hash);
|
.entry(thread)
|
||||||
|
.and_modify(|entry| entry.set_snoozed(!is_snoozed));
|
||||||
|
self.row_updates.push(thread);
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1352,33 +1316,10 @@ impl Component for CompactListing {
|
||||||
if !threads.thread_nodes.contains_key(&new_env_thread_hash) {
|
if !threads.thread_nodes.contains_key(&new_env_thread_hash) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let thread_group = melib::find_root_hash(
|
let thread: ThreadGroupHash =
|
||||||
&threads.thread_nodes,
|
threads.find_group(threads.thread_nodes()[&new_env_thread_hash].group);
|
||||||
threads.thread_nodes[&new_env_thread_hash].thread_group(),
|
if self.order.contains_key(&thread) {
|
||||||
);
|
self.row_updates.push(thread);
|
||||||
let (&thread_hash, &row): (&ThreadHash, &usize) = self
|
|
||||||
.order
|
|
||||||
.iter()
|
|
||||||
.find(|(n, _)| {
|
|
||||||
melib::find_root_hash(
|
|
||||||
&threads.thread_nodes,
|
|
||||||
threads.thread_nodes[&n].thread_group(),
|
|
||||||
) == thread_group
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let new_thread_hash = threads.root_set(row);
|
|
||||||
self.row_updates.push(new_thread_hash);
|
|
||||||
if let Some(row) = self.order.remove(&thread_hash) {
|
|
||||||
self.order.insert(new_thread_hash, row);
|
|
||||||
let selection_status = self.selection.remove(&thread_hash).unwrap();
|
|
||||||
self.selection.insert(new_thread_hash, selection_status);
|
|
||||||
for h in self.filtered_selection.iter_mut() {
|
|
||||||
if *h == thread_hash {
|
|
||||||
*h = new_thread_hash;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
|
|
|
@ -85,33 +85,33 @@ pub struct ConversationsListing {
|
||||||
length: usize,
|
length: usize,
|
||||||
sort: (SortField, SortOrder),
|
sort: (SortField, SortOrder),
|
||||||
subsort: (SortField, SortOrder),
|
subsort: (SortField, SortOrder),
|
||||||
all_threads: fnv::FnvHashSet<ThreadHash>,
|
all_threads: fnv::FnvHashSet<ThreadGroupHash>,
|
||||||
order: FnvHashMap<ThreadHash, usize>,
|
order: FnvHashMap<ThreadGroupHash, usize>,
|
||||||
/// Cache current view.
|
/// Cache current view.
|
||||||
content: CellBuffer,
|
content: CellBuffer,
|
||||||
|
|
||||||
filter_term: String,
|
filter_term: String,
|
||||||
filtered_selection: Vec<ThreadHash>,
|
filtered_selection: Vec<ThreadGroupHash>,
|
||||||
filtered_order: FnvHashMap<ThreadHash, usize>,
|
filtered_order: FnvHashMap<ThreadGroupHash, usize>,
|
||||||
selection: FnvHashMap<ThreadHash, bool>,
|
selection: FnvHashMap<ThreadGroupHash, bool>,
|
||||||
/// If we must redraw on next redraw event
|
/// If we must redraw on next redraw event
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
force_draw: bool,
|
force_draw: bool,
|
||||||
/// If `self.view` exists or not.
|
/// If `self.view` exists or not.
|
||||||
unfocused: bool,
|
unfocused: bool,
|
||||||
view: ThreadView,
|
view: ThreadView,
|
||||||
row_updates: SmallVec<[ThreadHash; 8]>,
|
row_updates: SmallVec<[ThreadGroupHash; 8]>,
|
||||||
|
|
||||||
movement: Option<PageMovement>,
|
movement: Option<PageMovement>,
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MailListingTrait for ConversationsListing {
|
impl MailListingTrait for ConversationsListing {
|
||||||
fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]> {
|
fn row_updates(&mut self) -> &mut SmallVec<[ThreadGroupHash; 8]> {
|
||||||
&mut self.row_updates
|
&mut self.row_updates
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadGroupHash; 8]> {
|
||||||
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
||||||
let i = [self.get_thread_under_cursor(self.cursor_pos.2, context)];
|
let i = [self.get_thread_under_cursor(self.cursor_pos.2, context)];
|
||||||
let cursor_iter;
|
let cursor_iter;
|
||||||
|
@ -149,23 +149,22 @@ impl ListingTrait for ConversationsListing {
|
||||||
if self.length == 0 {
|
if self.length == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let i = self.get_thread_under_cursor(idx, context);
|
let thread = self.get_thread_under_cursor(idx, context);
|
||||||
|
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
let account = &context.accounts[self.cursor_pos.0];
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
let threads = &account.collection.threads[&folder_hash];
|
||||||
let thread_node = &threads.thread_nodes[&i];
|
|
||||||
|
|
||||||
let fg_color = if thread_node.has_unseen() {
|
let fg_color = if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
};
|
};
|
||||||
let bg_color = if self.cursor_pos.2 == idx {
|
let bg_color = if self.cursor_pos.2 == idx {
|
||||||
Color::Byte(246)
|
Color::Byte(246)
|
||||||
} else if self.selection[&i] {
|
} else if self.selection[&thread] {
|
||||||
Color::Byte(210)
|
Color::Byte(210)
|
||||||
} else if thread_node.has_unseen() {
|
} else if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
@ -187,7 +186,7 @@ impl ListingTrait for ConversationsListing {
|
||||||
let (upper_left, bottom_right) = area;
|
let (upper_left, bottom_right) = area;
|
||||||
let width = self.content.size().0;
|
let width = self.content.size().0;
|
||||||
let (x, y) = upper_left;
|
let (x, y) = upper_left;
|
||||||
if self.cursor_pos.2 == idx || self.selection[&i] {
|
if self.cursor_pos.2 == idx || self.selection[&thread] {
|
||||||
for x in x..=get_x(bottom_right) {
|
for x in x..=get_x(bottom_right) {
|
||||||
grid[(x, y)].set_fg(fg_color);
|
grid[(x, y)].set_fg(fg_color);
|
||||||
grid[(x, y)].set_bg(bg_color);
|
grid[(x, y)].set_bg(bg_color);
|
||||||
|
@ -416,19 +415,19 @@ impl ListingTrait for ConversationsListing {
|
||||||
if !threads.thread_nodes.contains_key(&env_hash_thread_hash) {
|
if !threads.thread_nodes.contains_key(&env_hash_thread_hash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let thread_group =
|
let thread =
|
||||||
melib::find_root_hash(&threads.thread_nodes, env_hash_thread_hash);
|
threads.find_group(threads.thread_nodes[&env_hash_thread_hash].group);
|
||||||
if self.filtered_order.contains_key(&thread_group) {
|
if self.filtered_order.contains_key(&thread) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if self.all_threads.contains(&thread_group) {
|
if self.all_threads.contains(&thread) {
|
||||||
self.filtered_selection.push(thread_group);
|
self.filtered_selection.push(thread);
|
||||||
self.filtered_order
|
self.filtered_order
|
||||||
.insert(thread_group, self.filtered_selection.len() - 1);
|
.insert(thread, self.filtered_selection.len() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !self.filtered_selection.is_empty() {
|
if !self.filtered_selection.is_empty() {
|
||||||
threads.vec_inner_sort_by(
|
threads.group_inner_sort_by(
|
||||||
&mut self.filtered_selection,
|
&mut self.filtered_selection,
|
||||||
self.sort,
|
self.sort,
|
||||||
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
||||||
|
@ -439,7 +438,11 @@ impl ListingTrait for ConversationsListing {
|
||||||
self.content =
|
self.content =
|
||||||
CellBuffer::new_with_context(0, 0, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(0, 0, Cell::with_char(' '), context);
|
||||||
}
|
}
|
||||||
self.redraw_list(context);
|
self.redraw_list(
|
||||||
|
context,
|
||||||
|
Box::new(self.filtered_selection.clone().into_iter())
|
||||||
|
as Box<dyn Iterator<Item = ThreadGroupHash>>,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.cursor_pos.2 = 0;
|
self.cursor_pos.2 = 0;
|
||||||
|
@ -516,9 +519,10 @@ impl ConversationsListing {
|
||||||
e: &Envelope,
|
e: &Envelope,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
from: &Vec<Address>,
|
from: &Vec<Address>,
|
||||||
thread_node: &ThreadNode,
|
threads: &Threads,
|
||||||
is_snoozed: bool,
|
hash: ThreadGroupHash,
|
||||||
) -> EntryStrings {
|
) -> EntryStrings {
|
||||||
|
let thread = &threads.groups[&hash];
|
||||||
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.folder
|
.folder
|
||||||
|
@ -560,32 +564,26 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
let mut subject = e.subject().to_string();
|
let mut subject = e.subject().to_string();
|
||||||
subject.truncate_at_boundary(150);
|
subject.truncate_at_boundary(150);
|
||||||
if thread_node.len() > 0 {
|
if thread.len() > 1 {
|
||||||
EntryStrings {
|
EntryStrings {
|
||||||
date: DateString(ConversationsListing::format_date(
|
date: DateString(ConversationsListing::format_date(context, thread.date())),
|
||||||
context,
|
subject: SubjectString(format!("{} ({})", subject, thread.len(),)),
|
||||||
thread_node.date(),
|
|
||||||
)),
|
|
||||||
subject: SubjectString(format!("{} ({})", subject, thread_node.len(),)),
|
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "📎" } else { "" },
|
if e.has_attachments() { "📎" } else { "" },
|
||||||
if is_snoozed { "💤" } else { "" }
|
if thread.snoozed() { "💤" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((from) as comma_sep_list)),
|
from: FromString(address_list!((from) as comma_sep_list)),
|
||||||
tags: TagString(tags, colors),
|
tags: TagString(tags, colors),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EntryStrings {
|
EntryStrings {
|
||||||
date: DateString(ConversationsListing::format_date(
|
date: DateString(ConversationsListing::format_date(context, thread.date())),
|
||||||
context,
|
|
||||||
thread_node.date(),
|
|
||||||
)),
|
|
||||||
subject: SubjectString(subject),
|
subject: SubjectString(subject),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "📎" } else { "" },
|
if e.has_attachments() { "📎" } else { "" },
|
||||||
if is_snoozed { "💤" } else { "" }
|
if thread.snoozed() { "💤" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((from) as comma_sep_list)),
|
from: FromString(address_list!((from) as comma_sep_list)),
|
||||||
tags: TagString(tags, colors),
|
tags: TagString(tags, colors),
|
||||||
|
@ -638,16 +636,31 @@ impl ConversationsListing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&folder_hash];
|
||||||
|
self.all_threads.clear();
|
||||||
|
let mut roots = threads.roots();
|
||||||
|
threads.group_inner_sort_by(
|
||||||
|
&mut roots,
|
||||||
|
self.sort,
|
||||||
|
&context.accounts[self.cursor_pos.0].collection.envelopes,
|
||||||
|
);
|
||||||
|
|
||||||
|
self.redraw_list(
|
||||||
|
context,
|
||||||
|
Box::new(roots.into_iter()) as Box<dyn Iterator<Item = ThreadGroupHash>>,
|
||||||
|
);
|
||||||
|
|
||||||
if old_cursor_pos == self.new_cursor_pos {
|
if old_cursor_pos == self.new_cursor_pos {
|
||||||
self.view.update(context);
|
self.view.update(context);
|
||||||
} else if self.unfocused {
|
} else if self.unfocused {
|
||||||
self.view = ThreadView::new(self.new_cursor_pos, None, context);
|
let thread_group = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
}
|
|
||||||
|
|
||||||
self.redraw_list(context);
|
self.view = ThreadView::new(self.new_cursor_pos, thread_group, None, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn redraw_list(&mut self, context: &Context) {
|
fn redraw_list(&mut self, context: &Context, items: Box<dyn Iterator<Item = ThreadGroupHash>>) {
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
let account = &context.accounts[self.cursor_pos.0];
|
||||||
let mailbox = &account[self.cursor_pos.1].unwrap();
|
let mailbox = &account[self.cursor_pos.1].unwrap();
|
||||||
|
|
||||||
|
@ -658,33 +671,21 @@ impl ConversationsListing {
|
||||||
let mut rows = Vec::with_capacity(1024);
|
let mut rows = Vec::with_capacity(1024);
|
||||||
let mut max_entry_columns = 0;
|
let mut max_entry_columns = 0;
|
||||||
|
|
||||||
threads.sort_by(self.sort, self.subsort, &account.collection.envelopes);
|
|
||||||
|
|
||||||
let mut refresh_mailbox = false;
|
|
||||||
let threads_iter = if self.filter_term.is_empty() {
|
|
||||||
refresh_mailbox = true;
|
|
||||||
self.all_threads.clear();
|
|
||||||
Box::new(threads.root_iter()) as Box<dyn Iterator<Item = ThreadHash>>
|
|
||||||
} else {
|
|
||||||
Box::new(self.filtered_selection.iter().map(|h| *h))
|
|
||||||
as Box<dyn Iterator<Item = ThreadHash>>
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut from_address_list = Vec::new();
|
let mut from_address_list = Vec::new();
|
||||||
let mut from_address_set: std::collections::HashSet<Vec<u8>> =
|
let mut from_address_set: std::collections::HashSet<Vec<u8>> =
|
||||||
std::collections::HashSet::new();
|
std::collections::HashSet::new();
|
||||||
for (idx, root_idx) in threads_iter.enumerate() {
|
for (idx, thread) in items.enumerate() {
|
||||||
self.length += 1;
|
self.length += 1;
|
||||||
let thread_node = &threads.thread_nodes()[&root_idx];
|
let thread_node = &threads.thread_nodes()[&threads.groups[&thread].root().unwrap()];
|
||||||
let i = thread_node.message().unwrap_or_else(|| {
|
let root_env_hash = thread_node.message().unwrap_or_else(|| {
|
||||||
let mut iter_ptr = thread_node.children()[0];
|
let mut iter_ptr = thread_node.children()[0];
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||||
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
||||||
}
|
}
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||||
});
|
});
|
||||||
if !context.accounts[self.cursor_pos.0].contains_key(i) {
|
if !context.accounts[self.cursor_pos.0].contains_key(root_env_hash) {
|
||||||
debug!("key = {}", i);
|
debug!("key = {}", root_env_hash);
|
||||||
debug!(
|
debug!(
|
||||||
"name = {} {}",
|
"name = {} {}",
|
||||||
mailbox.name(),
|
mailbox.name(),
|
||||||
|
@ -696,14 +697,8 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
from_address_list.clear();
|
from_address_list.clear();
|
||||||
from_address_set.clear();
|
from_address_set.clear();
|
||||||
let mut stack: SmallVec<[ThreadHash; 8]> = SmallVec::new();
|
for (_, h) in threads.thread_group_iter(thread) {
|
||||||
stack.push(root_idx);
|
let env_hash = threads.thread_nodes()[&h].message().unwrap();
|
||||||
while let Some(h) = stack.pop() {
|
|
||||||
let env_hash = if let Some(h) = threads.thread_nodes()[&h].message() {
|
|
||||||
h
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
let envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
let envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
||||||
.collection
|
.collection
|
||||||
|
@ -715,21 +710,13 @@ impl ConversationsListing {
|
||||||
from_address_set.insert(addr.raw().to_vec());
|
from_address_set.insert(addr.raw().to_vec());
|
||||||
from_address_list.push(addr.clone());
|
from_address_list.push(addr.clone());
|
||||||
}
|
}
|
||||||
for c in threads.thread_nodes()[&h].children() {
|
|
||||||
stack.push(*c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
let root_envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
||||||
|
.collection
|
||||||
|
.get_env(root_env_hash);
|
||||||
|
|
||||||
let root_envelope: &EnvelopeRef =
|
let strings =
|
||||||
&context.accounts[self.cursor_pos.0].collection.get_env(i);
|
self.make_entry_string(root_envelope, context, &from_address_list, threads, thread);
|
||||||
|
|
||||||
let strings = self.make_entry_string(
|
|
||||||
root_envelope,
|
|
||||||
context,
|
|
||||||
&from_address_list,
|
|
||||||
thread_node,
|
|
||||||
threads.is_snoozed(root_idx),
|
|
||||||
);
|
|
||||||
max_entry_columns = std::cmp::max(
|
max_entry_columns = std::cmp::max(
|
||||||
max_entry_columns,
|
max_entry_columns,
|
||||||
strings.flag.len()
|
strings.flag.len()
|
||||||
|
@ -742,20 +729,12 @@ impl ConversationsListing {
|
||||||
max_entry_columns,
|
max_entry_columns,
|
||||||
strings.date.len() + 1 + strings.from.grapheme_width(),
|
strings.date.len() + 1 + strings.from.grapheme_width(),
|
||||||
);
|
);
|
||||||
rows.push(strings);
|
rows.push(((idx, (thread, root_env_hash)), strings));
|
||||||
if refresh_mailbox {
|
self.all_threads.insert(thread);
|
||||||
self.all_threads.insert(root_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.order.insert(root_idx, idx);
|
self.order.insert(thread, idx);
|
||||||
self.selection.insert(root_idx, false);
|
self.selection.insert(thread, false);
|
||||||
}
|
}
|
||||||
let ConversationsListing {
|
|
||||||
ref mut selection,
|
|
||||||
ref order,
|
|
||||||
..
|
|
||||||
} = self;
|
|
||||||
selection.retain(|e, _| order.contains_key(e));
|
|
||||||
|
|
||||||
let width = max_entry_columns;
|
let width = max_entry_columns;
|
||||||
self.content =
|
self.content =
|
||||||
|
@ -766,31 +745,17 @@ impl ConversationsListing {
|
||||||
} else {
|
} else {
|
||||||
Color::Byte(235)
|
Color::Byte(235)
|
||||||
};
|
};
|
||||||
let threads_iter = if self.filter_term.is_empty() {
|
|
||||||
Box::new(threads.root_iter()) as Box<dyn Iterator<Item = ThreadHash>>
|
|
||||||
} else {
|
|
||||||
Box::new(self.filtered_selection.iter().map(|h| *h))
|
|
||||||
as Box<dyn Iterator<Item = ThreadHash>>
|
|
||||||
};
|
|
||||||
|
|
||||||
for ((idx, root_idx), strings) in threads_iter.enumerate().zip(rows) {
|
for ((idx, (thread, root_env_hash)), strings) in rows {
|
||||||
let thread_node = &threads.thread_nodes()[&root_idx];
|
if !context.accounts[self.cursor_pos.0].contains_key(root_env_hash) {
|
||||||
let i = thread_node.message().unwrap_or_else(|| {
|
|
||||||
let mut iter_ptr = thread_node.children()[0];
|
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
|
||||||
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
|
||||||
}
|
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
|
||||||
});
|
|
||||||
if !context.accounts[self.cursor_pos.0].contains_key(i) {
|
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
let fg_color = if thread_node.has_unseen() {
|
let fg_color = if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
};
|
};
|
||||||
let bg_color = if thread_node.has_unseen() {
|
let bg_color = if threads.groups[&thread].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
@ -930,7 +895,7 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash {
|
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadGroupHash {
|
||||||
//let account = &context.accounts[self.cursor_pos.0];
|
//let account = &context.accounts[self.cursor_pos.0];
|
||||||
//let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
//let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
//let threads = &account.collection.threads[&folder_hash];
|
//let threads = &account.collection.threads[&folder_hash];
|
||||||
|
@ -950,20 +915,23 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) {
|
fn update_line(&mut self, context: &Context, thread_hash: ThreadGroupHash) {
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
let account = &context.accounts[self.cursor_pos.0];
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
let threads = &account.collection.threads[&folder_hash];
|
||||||
let thread_node = &threads.thread_nodes[&thread_hash];
|
|
||||||
let idx: usize = self.order[&thread_hash];
|
let idx: usize = self.order[&thread_hash];
|
||||||
let width = self.content.size().0;
|
let width = self.content.size().0;
|
||||||
|
|
||||||
let fg_color = if thread_node.has_unseen() {
|
let env_hash = threads.thread_nodes()[&threads.groups[&thread_hash].root().unwrap()]
|
||||||
|
.message()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let fg_color = if threads.groups[&thread_hash].unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
};
|
};
|
||||||
let bg_color = if thread_node.has_unseen() {
|
let bg_color = if threads.groups[&thread_hash].unseen() > 0 {
|
||||||
Color::Byte(251)
|
Color::Byte(251)
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
@ -976,14 +944,8 @@ impl ConversationsListing {
|
||||||
let mut from_address_list = Vec::new();
|
let mut from_address_list = Vec::new();
|
||||||
let mut from_address_set: std::collections::HashSet<Vec<u8>> =
|
let mut from_address_set: std::collections::HashSet<Vec<u8>> =
|
||||||
std::collections::HashSet::new();
|
std::collections::HashSet::new();
|
||||||
let mut stack: SmallVec<[ThreadHash; 8]> = SmallVec::new();
|
for (_, h) in threads.thread_group_iter(thread_hash) {
|
||||||
stack.push(thread_hash);
|
let env_hash = threads.thread_nodes()[&h].message().unwrap();
|
||||||
while let Some(h) = stack.pop() {
|
|
||||||
let env_hash = if let Some(h) = threads.thread_nodes()[&h].message() {
|
|
||||||
h
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
let envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
let envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
||||||
.collection
|
.collection
|
||||||
|
@ -995,19 +957,10 @@ impl ConversationsListing {
|
||||||
from_address_set.insert(addr.raw().to_vec());
|
from_address_set.insert(addr.raw().to_vec());
|
||||||
from_address_list.push(addr.clone());
|
from_address_list.push(addr.clone());
|
||||||
}
|
}
|
||||||
for c in threads.thread_nodes()[&h].children() {
|
|
||||||
stack.push(*c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let env_hash = threads[&thread_hash].message().unwrap();
|
|
||||||
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
||||||
let strings = self.make_entry_string(
|
let strings =
|
||||||
&envelope,
|
self.make_entry_string(&envelope, context, &from_address_list, threads, thread_hash);
|
||||||
context,
|
|
||||||
&from_address_list,
|
|
||||||
&threads[&thread_hash],
|
|
||||||
threads.is_snoozed(thread_hash),
|
|
||||||
);
|
|
||||||
drop(envelope);
|
drop(envelope);
|
||||||
/* draw flags */
|
/* draw flags */
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
|
@ -1215,27 +1168,8 @@ impl Component for ConversationsListing {
|
||||||
k == shortcuts[ConversationsListing::DESCRIPTION]["open_thread"]
|
k == shortcuts[ConversationsListing::DESCRIPTION]["open_thread"]
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
if self.length == 0 {
|
let thread = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
return true;
|
self.view = ThreadView::new(self.cursor_pos, thread, None, context);
|
||||||
}
|
|
||||||
|
|
||||||
if self.filter_term.is_empty() {
|
|
||||||
self.view = ThreadView::new(self.cursor_pos, None, context);
|
|
||||||
} else if !self.filtered_selection.is_empty() {
|
|
||||||
let mut temp = self.cursor_pos;
|
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let root_thread_index = threads.root_iter().position(|t| t == thread_hash);
|
|
||||||
if let Some(pos) = root_thread_index {
|
|
||||||
temp.2 = pos;
|
|
||||||
self.view = ThreadView::new(temp, Some(thread_hash), context);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.unfocused = true;
|
self.unfocused = true;
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1260,8 +1194,8 @@ impl Component for ConversationsListing {
|
||||||
key == shortcuts[ConversationsListing::DESCRIPTION]["select_entry"]
|
key == shortcuts[ConversationsListing::DESCRIPTION]["select_entry"]
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
let thread = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
self.selection.entry(thread_hash).and_modify(|e| *e = !*e);
|
self.selection.entry(thread).and_modify(|e| *e = !*e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
||||||
|
@ -1275,33 +1209,10 @@ impl Component for ConversationsListing {
|
||||||
if !threads.thread_nodes.contains_key(&new_env_thread_hash) {
|
if !threads.thread_nodes.contains_key(&new_env_thread_hash) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let thread_group = melib::find_root_hash(
|
let thread: ThreadGroupHash =
|
||||||
&threads.thread_nodes,
|
threads.find_group(threads.thread_nodes()[&new_env_thread_hash].group);
|
||||||
threads.thread_nodes[&new_env_thread_hash].thread_group(),
|
if self.order.contains_key(&thread) {
|
||||||
);
|
self.row_updates.push(thread);
|
||||||
let (&thread_hash, &row): (&ThreadHash, &usize) = self
|
|
||||||
.order
|
|
||||||
.iter()
|
|
||||||
.find(|(n, _)| {
|
|
||||||
melib::find_root_hash(
|
|
||||||
&threads.thread_nodes,
|
|
||||||
threads.thread_nodes[&n].thread_group(),
|
|
||||||
) == thread_group
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let new_thread_hash = threads.root_set(row);
|
|
||||||
self.row_updates.push(new_thread_hash);
|
|
||||||
if let Some(row) = self.order.remove(&thread_hash) {
|
|
||||||
self.order.insert(new_thread_hash, row);
|
|
||||||
let selection_status = self.selection.remove(&thread_hash).unwrap();
|
|
||||||
self.selection.insert(new_thread_hash, selection_status);
|
|
||||||
for h in self.filtered_selection.iter_mut() {
|
|
||||||
if *h == thread_hash {
|
|
||||||
*h = new_thread_hash;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
|
@ -1313,6 +1224,7 @@ impl Component for ConversationsListing {
|
||||||
Action::SubSort(field, order) if !self.unfocused => {
|
Action::SubSort(field, order) if !self.unfocused => {
|
||||||
debug!("SubSort {:?} , {:?}", field, order);
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
|
// FIXME subsort
|
||||||
//if !self.filtered_selection.is_empty() {
|
//if !self.filtered_selection.is_empty() {
|
||||||
// let threads = &account.collection.threads[&folder_hash];
|
// let threads = &account.collection.threads[&folder_hash];
|
||||||
// threads.vec_inner_sort_by(&mut self.filtered_selection, self.sort, &account.collection);
|
// threads.vec_inner_sort_by(&mut self.filtered_selection, self.sort, &account.collection);
|
||||||
|
@ -1323,6 +1235,8 @@ impl Component for ConversationsListing {
|
||||||
}
|
}
|
||||||
Action::Sort(field, order) if !self.unfocused => {
|
Action::Sort(field, order) if !self.unfocused => {
|
||||||
debug!("Sort {:?} , {:?}", field, order);
|
debug!("Sort {:?} , {:?}", field, order);
|
||||||
|
// FIXME sort
|
||||||
|
/*
|
||||||
self.sort = (*field, *order);
|
self.sort = (*field, *order);
|
||||||
if !self.filtered_selection.is_empty() {
|
if !self.filtered_selection.is_empty() {
|
||||||
let folder_hash = context.accounts[self.cursor_pos.0]
|
let folder_hash = context.accounts[self.cursor_pos.0]
|
||||||
|
@ -1341,17 +1255,20 @@ impl Component for ConversationsListing {
|
||||||
} else {
|
} else {
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::ToggleThreadSnooze if !self.unfocused => {
|
Action::ToggleThreadSnooze if !self.unfocused => {
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
let thread = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
let account = &mut context.accounts[self.cursor_pos.0];
|
let account = &mut context.accounts[self.cursor_pos.0];
|
||||||
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
||||||
let threads = account.collection.threads.entry(folder_hash).or_default();
|
let threads = account.collection.threads.entry(folder_hash).or_default();
|
||||||
let root_node = threads.thread_nodes.entry(thread_hash).or_default();
|
let is_snoozed = threads.groups[&thread].snoozed();
|
||||||
let is_snoozed = root_node.snoozed();
|
threads
|
||||||
root_node.set_snoozed(!is_snoozed);
|
.groups
|
||||||
self.row_updates.push(thread_hash);
|
.entry(thread)
|
||||||
|
.and_modify(|entry| entry.set_snoozed(!is_snoozed));
|
||||||
|
self.row_updates.push(thread);
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,18 +71,20 @@ pub struct PlainListing {
|
||||||
unfocused: bool,
|
unfocused: bool,
|
||||||
view: MailView,
|
view: MailView,
|
||||||
row_updates: SmallVec<[EnvelopeHash; 8]>,
|
row_updates: SmallVec<[EnvelopeHash; 8]>,
|
||||||
_row_updates: SmallVec<[ThreadHash; 8]>,
|
_row_updates: SmallVec<[ThreadGroupHash; 8]>,
|
||||||
|
|
||||||
movement: Option<PageMovement>,
|
movement: Option<PageMovement>,
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MailListingTrait for PlainListing {
|
impl MailListingTrait for PlainListing {
|
||||||
fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]> {
|
fn row_updates(&mut self) -> &mut SmallVec<[ThreadGroupHash; 8]> {
|
||||||
&mut self._row_updates
|
&mut self._row_updates
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
fn get_focused_items(&self, context: &Context) -> SmallVec<[ThreadGroupHash; 8]> {
|
||||||
|
return SmallVec::new();
|
||||||
|
/*
|
||||||
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
let is_selection_empty = self.selection.values().cloned().any(std::convert::identity);
|
||||||
if is_selection_empty {
|
if is_selection_empty {
|
||||||
self.selection
|
self.selection
|
||||||
|
@ -95,6 +97,7 @@ impl MailListingTrait for PlainListing {
|
||||||
ret.push(self.get_thread_under_cursor(self.cursor_pos.2, context));
|
ret.push(self.get_thread_under_cursor(self.cursor_pos.2, context));
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub struct ThreadListing {
|
||||||
/// Cache current view.
|
/// Cache current view.
|
||||||
content: CellBuffer,
|
content: CellBuffer,
|
||||||
|
|
||||||
row_updates: SmallVec<[ThreadHash; 8]>,
|
row_updates: SmallVec<[ThreadGroupHash; 8]>,
|
||||||
locations: Vec<EnvelopeHash>,
|
locations: Vec<EnvelopeHash>,
|
||||||
/// If we must redraw on next redraw event
|
/// If we must redraw on next redraw event
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
|
@ -50,11 +50,11 @@ pub struct ThreadListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MailListingTrait for ThreadListing {
|
impl MailListingTrait for ThreadListing {
|
||||||
fn row_updates(&mut self) -> &mut SmallVec<[ThreadHash; 8]> {
|
fn row_updates(&mut self) -> &mut SmallVec<[ThreadGroupHash; 8]> {
|
||||||
&mut self.row_updates
|
&mut self.row_updates
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadHash; 8]> {
|
fn get_focused_items(&self, _context: &Context) -> SmallVec<[ThreadGroupHash; 8]> {
|
||||||
SmallVec::new()
|
SmallVec::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,17 +777,9 @@ impl Component for MailView {
|
||||||
{
|
{
|
||||||
let account = &context.accounts[self.coordinates.0];
|
let account = &context.accounts[self.coordinates.0];
|
||||||
let folder_hash = account[self.coordinates.1].unwrap().folder.hash();
|
let folder_hash = account[self.coordinates.1].unwrap().folder.hash();
|
||||||
let envelope: EnvelopeRef = account.collection.get_env(self.coordinates.2);
|
|
||||||
let thread_hash = envelope.thread();
|
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let root_thread_hash = melib::find_root_hash(&threads.thread_nodes, thread_hash);
|
|
||||||
let root_idx = threads
|
|
||||||
.root_iter()
|
|
||||||
.position(|t| t == root_thread_hash)
|
|
||||||
.unwrap();
|
|
||||||
context.replies.push_back(UIEvent::Action(Tab(Reply(
|
context.replies.push_back(UIEvent::Action(Tab(Reply(
|
||||||
(self.coordinates.0, self.coordinates.1, root_idx),
|
(self.coordinates.0, folder_hash),
|
||||||
thread_hash,
|
self.coordinates.2,
|
||||||
))));
|
))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ pub struct ThreadView {
|
||||||
new_expanded_pos: usize,
|
new_expanded_pos: usize,
|
||||||
reversed: bool,
|
reversed: bool,
|
||||||
coordinates: (usize, usize, usize),
|
coordinates: (usize, usize, usize),
|
||||||
|
thread_group: ThreadGroupHash,
|
||||||
mailview: MailView,
|
mailview: MailView,
|
||||||
show_mailview: bool,
|
show_mailview: bool,
|
||||||
show_thread: bool,
|
show_thread: bool,
|
||||||
|
@ -75,6 +76,7 @@ impl ThreadView {
|
||||||
*/
|
*/
|
||||||
pub fn new(
|
pub fn new(
|
||||||
coordinates: (usize, usize, usize),
|
coordinates: (usize, usize, usize),
|
||||||
|
thread_group: ThreadGroupHash,
|
||||||
expanded_hash: Option<ThreadHash>,
|
expanded_hash: Option<ThreadHash>,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -82,6 +84,7 @@ impl ThreadView {
|
||||||
reversed: false,
|
reversed: false,
|
||||||
initiated: false,
|
initiated: false,
|
||||||
coordinates,
|
coordinates,
|
||||||
|
thread_group,
|
||||||
mailview: MailView::default(),
|
mailview: MailView::default(),
|
||||||
show_mailview: true,
|
show_mailview: true,
|
||||||
show_thread: true,
|
show_thread: true,
|
||||||
|
@ -163,7 +166,7 @@ impl ThreadView {
|
||||||
let mailbox = &account[self.coordinates.1].unwrap();
|
let mailbox = &account[self.coordinates.1].unwrap();
|
||||||
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
||||||
|
|
||||||
let thread_iter = threads.thread_iter(self.coordinates.2);
|
let thread_iter = threads.thread_group_iter(self.thread_group);
|
||||||
self.entries.clear();
|
self.entries.clear();
|
||||||
for (line, (ind, thread_hash)) in thread_iter.enumerate() {
|
for (line, (ind, thread_hash)) in thread_iter.enumerate() {
|
||||||
let entry = if let Some(msg_hash) = threads.thread_nodes()[&thread_hash].message() {
|
let entry = if let Some(msg_hash) = threads.thread_nodes()[&thread_hash].message() {
|
||||||
|
@ -633,7 +636,12 @@ impl ThreadView {
|
||||||
let account = &context.accounts[self.coordinates.0];
|
let account = &context.accounts[self.coordinates.0];
|
||||||
let mailbox = &account[self.coordinates.1].unwrap();
|
let mailbox = &account[self.coordinates.1].unwrap();
|
||||||
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
||||||
let thread_node = &threads.thread_nodes()[&threads.root_set(self.coordinates.2)];
|
let thread_root = threads
|
||||||
|
.thread_group_iter(self.thread_group)
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.1;
|
||||||
|
let thread_node = &threads.thread_nodes()[&thread_root];
|
||||||
let i = thread_node.message().unwrap_or_else(|| {
|
let i = thread_node.message().unwrap_or_else(|| {
|
||||||
let mut iter_ptr = thread_node.children()[0];
|
let mut iter_ptr = thread_node.children()[0];
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||||
|
@ -723,7 +731,12 @@ impl ThreadView {
|
||||||
let account = &context.accounts[self.coordinates.0];
|
let account = &context.accounts[self.coordinates.0];
|
||||||
let mailbox = &account[self.coordinates.1].unwrap();
|
let mailbox = &account[self.coordinates.1].unwrap();
|
||||||
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
||||||
let thread_node = &threads.thread_nodes()[&threads.root_set(self.coordinates.2)];
|
let thread_root = threads
|
||||||
|
.thread_group_iter(self.thread_group)
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.1;
|
||||||
|
let thread_node = &threads.thread_nodes()[&thread_root];
|
||||||
let i = thread_node.message().unwrap_or_else(|| {
|
let i = thread_node.message().unwrap_or_else(|| {
|
||||||
let mut iter_ptr = thread_node.children()[0];
|
let mut iter_ptr = thread_node.children()[0];
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||||
|
|
|
@ -594,11 +594,12 @@ impl Account {
|
||||||
return Some(UIEvent::MailboxUpdate((self.index, folder_hash)));
|
return Some(UIEvent::MailboxUpdate((self.index, folder_hash)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let thread_node = {
|
let thread = {
|
||||||
let thread_hash = &mut self.collection.get_env(env_hash).thread();
|
let thread_hash = self.collection.get_env(env_hash).thread();
|
||||||
&self.collection.threads[&folder_hash][&thread_hash]
|
self.collection.threads[&folder_hash]
|
||||||
|
.find_group(self.collection.threads[&folder_hash][&thread_hash].group)
|
||||||
};
|
};
|
||||||
if thread_node.snoozed() {
|
if self.collection.threads[&folder_hash].groups[&thread].snoozed() {
|
||||||
return Some(UIEvent::MailboxUpdate((self.index, folder_hash)));
|
return Some(UIEvent::MailboxUpdate((self.index, folder_hash)));
|
||||||
}
|
}
|
||||||
if is_seen || is_draft {
|
if is_seen || is_draft {
|
||||||
|
|
|
@ -24,8 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::components::Component;
|
use crate::components::Component;
|
||||||
use melib::backends::FolderOperation;
|
use melib::backends::{FolderHash, FolderOperation};
|
||||||
use melib::thread::ThreadHash;
|
|
||||||
pub use melib::thread::{SortField, SortOrder};
|
pub use melib::thread::{SortField, SortOrder};
|
||||||
use melib::{Draft, EnvelopeHash};
|
use melib::{Draft, EnvelopeHash};
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ pub enum ListingAction {
|
||||||
pub enum TabAction {
|
pub enum TabAction {
|
||||||
New(Option<Box<dyn Component>>),
|
New(Option<Box<dyn Component>>),
|
||||||
NewDraft(usize, Option<Draft>),
|
NewDraft(usize, Option<Draft>),
|
||||||
Reply((usize, usize, usize), ThreadHash), // thread coordinates (account, mailbox, root_set idx) and thread hash
|
Reply((usize, FolderHash), EnvelopeHash), // thread coordinates (account, mailbox) and envelope
|
||||||
Close,
|
Close,
|
||||||
Edit(usize, EnvelopeHash), // account_position, envelope hash
|
Edit(usize, EnvelopeHash), // account_position, envelope hash
|
||||||
Kill(Uuid),
|
Kill(Uuid),
|
||||||
|
|
Loading…
Reference in New Issue