ui/listings: add folder_hash field
No reason not to have it stored and discover it whenever it's needed.async
parent
e07b5faf6e
commit
63ff25b36a
|
@ -51,6 +51,7 @@ pub struct CompactListing {
|
||||||
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
||||||
cursor_pos: (usize, usize, usize),
|
cursor_pos: (usize, usize, usize),
|
||||||
new_cursor_pos: (usize, usize, usize),
|
new_cursor_pos: (usize, usize, usize),
|
||||||
|
folder_hash: FolderHash,
|
||||||
length: usize,
|
length: usize,
|
||||||
sort: (SortField, SortOrder),
|
sort: (SortField, SortOrder),
|
||||||
subsort: (SortField, SortOrder),
|
subsort: (SortField, SortOrder),
|
||||||
|
@ -121,8 +122,7 @@ impl ListingTrait for CompactListing {
|
||||||
let thread_hash = self.get_thread_under_cursor(idx, context);
|
let thread_hash = 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 threads = &account.collection.threads[&self.folder_hash];
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let thread = threads.thread_ref(thread_hash);
|
let thread = threads.thread_ref(thread_hash);
|
||||||
|
|
||||||
let fg_color = if thread.unseen() > 0 {
|
let fg_color = if thread.unseen() > 0 {
|
||||||
|
@ -432,19 +432,15 @@ impl ListingTrait for CompactListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
match account.search(&self.filter_term, self.sort, self.folder_hash) {
|
||||||
match account.search(&self.filter_term, self.sort, folder_hash) {
|
|
||||||
Ok(results) => {
|
Ok(results) => {
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
let threads = &account.collection.threads[&self.folder_hash];
|
||||||
for env_hash in results {
|
for env_hash in results {
|
||||||
if !account.collection.contains_key(&env_hash) {
|
if !account.collection.contains_key(&env_hash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let env_thread_node_hash = account.collection.get_env(env_hash).thread();
|
let env_thread_node_hash = account.collection.get_env(env_hash).thread();
|
||||||
if !threads
|
if !threads.thread_nodes.contains_key(&env_thread_node_hash) {
|
||||||
.thread_nodes
|
|
||||||
.contains_key(&env_thread_node_hash)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let thread =
|
let thread =
|
||||||
|
@ -526,6 +522,7 @@ impl CompactListing {
|
||||||
CompactListing {
|
CompactListing {
|
||||||
cursor_pos: (0, 1, 0),
|
cursor_pos: (0, 1, 0),
|
||||||
new_cursor_pos: (0, 0, 0),
|
new_cursor_pos: (0, 0, 0),
|
||||||
|
folder_hash: 0,
|
||||||
length: 0,
|
length: 0,
|
||||||
sort: (Default::default(), Default::default()),
|
sort: (Default::default(), Default::default()),
|
||||||
subsort: (SortField::Date, SortOrder::Desc),
|
subsort: (SortField::Date, SortOrder::Desc),
|
||||||
|
@ -554,11 +551,7 @@ impl CompactListing {
|
||||||
hash: ThreadHash,
|
hash: ThreadHash,
|
||||||
) -> EntryStrings {
|
) -> EntryStrings {
|
||||||
let thread = threads.thread_ref(hash);
|
let thread = threads.thread_ref(hash);
|
||||||
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
let folder = &context.accounts[self.cursor_pos.0].folder_confs[&self.folder_hash];
|
||||||
.unwrap()
|
|
||||||
.folder
|
|
||||||
.hash();
|
|
||||||
let folder = &context.accounts[self.cursor_pos.0].folder_confs[&folder_hash];
|
|
||||||
let mut tags = String::new();
|
let mut tags = String::new();
|
||||||
let mut colors: SmallVec<[_; 8]> = SmallVec::new();
|
let mut colors: SmallVec<[_; 8]> = SmallVec::new();
|
||||||
let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap();
|
let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap();
|
||||||
|
@ -635,7 +628,7 @@ impl CompactListing {
|
||||||
}
|
}
|
||||||
self.cursor_pos.1 = self.new_cursor_pos.1;
|
self.cursor_pos.1 = self.new_cursor_pos.1;
|
||||||
self.cursor_pos.0 = self.new_cursor_pos.0;
|
self.cursor_pos.0 = self.new_cursor_pos.0;
|
||||||
let folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
self.folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
||||||
.folders_order
|
.folders_order
|
||||||
.get(self.cursor_pos.1)
|
.get(self.cursor_pos.1)
|
||||||
{
|
{
|
||||||
|
@ -648,10 +641,11 @@ impl CompactListing {
|
||||||
|
|
||||||
// Get mailbox as a reference.
|
// Get mailbox as a reference.
|
||||||
//
|
//
|
||||||
match context.accounts[self.cursor_pos.0].status(folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string();
|
let message: String =
|
||||||
|
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
||||||
self.data_columns.columns[0] =
|
self.data_columns.columns[0] =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
|
@ -668,7 +662,7 @@ impl CompactListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&folder_hash];
|
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&self.folder_hash];
|
||||||
self.all_threads.clear();
|
self.all_threads.clear();
|
||||||
let mut roots = threads.roots();
|
let mut roots = threads.roots();
|
||||||
threads.group_inner_sort_by(
|
threads.group_inner_sort_by(
|
||||||
|
@ -961,8 +955,6 @@ impl CompactListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash {
|
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash {
|
||||||
//let account = &context.accounts[self.cursor_pos.0];
|
|
||||||
//let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash();
|
|
||||||
if self.filter_term.is_empty() {
|
if self.filter_term.is_empty() {
|
||||||
*self
|
*self
|
||||||
.order
|
.order
|
||||||
|
@ -980,8 +972,7 @@ impl CompactListing {
|
||||||
|
|
||||||
fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) {
|
fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) {
|
||||||
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 threads = &account.collection.threads[&self.folder_hash];
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let thread = threads.thread_ref(thread_hash);
|
let thread = threads.thread_ref(thread_hash);
|
||||||
let thread_node_hash = threads.thread_group_iter(thread_hash).next().unwrap().1;
|
let thread_node_hash = threads.thread_group_iter(thread_hash).next().unwrap().1;
|
||||||
if let Some(env_hash) = threads.thread_nodes()[&thread_node_hash].message() {
|
if let Some(env_hash) = threads.thread_nodes()[&thread_node_hash].message() {
|
||||||
|
@ -1266,11 +1257,10 @@ impl Component for CompactListing {
|
||||||
Action::ToggleThreadSnooze if !self.unfocused => {
|
Action::ToggleThreadSnooze if !self.unfocused => {
|
||||||
let thread = 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();
|
|
||||||
account
|
account
|
||||||
.collection
|
.collection
|
||||||
.threads
|
.threads
|
||||||
.entry(folder_hash)
|
.entry(self.folder_hash)
|
||||||
.and_modify(|threads| {
|
.and_modify(|threads| {
|
||||||
let is_snoozed = threads.thread_ref(thread).snoozed();
|
let is_snoozed = threads.thread_ref(thread).snoozed();
|
||||||
threads.thread_ref_mut(thread).set_snoozed(!is_snoozed);
|
threads.thread_ref_mut(thread).set_snoozed(!is_snoozed);
|
||||||
|
@ -1288,29 +1278,18 @@ impl Component for CompactListing {
|
||||||
}
|
}
|
||||||
match *event {
|
match *event {
|
||||||
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
if (*idxa, *idxf) == (self.new_cursor_pos.0, self.folder_hash) =>
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| (*idxa, *idxf) == (self.new_cursor_pos.0, folder_hash))
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
{
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::StartupCheck(ref f)
|
UIEvent::StartupCheck(ref f) if *f == self.folder_hash => {
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| *f == folder_hash)
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
||||||
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 threads = &account.collection.threads[&self.folder_hash];
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
if !account.collection.contains_key(&new_hash) {
|
if !account.collection.contains_key(&new_hash) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ pub struct ConversationsListing {
|
||||||
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
||||||
cursor_pos: (usize, usize, usize),
|
cursor_pos: (usize, usize, usize),
|
||||||
new_cursor_pos: (usize, usize, usize),
|
new_cursor_pos: (usize, usize, usize),
|
||||||
|
folder_hash: FolderHash,
|
||||||
length: usize,
|
length: usize,
|
||||||
sort: (SortField, SortOrder),
|
sort: (SortField, SortOrder),
|
||||||
subsort: (SortField, SortOrder),
|
subsort: (SortField, SortOrder),
|
||||||
|
@ -152,8 +153,7 @@ impl ListingTrait for ConversationsListing {
|
||||||
let thread_hash = self.get_thread_under_cursor(idx, context);
|
let thread_hash = 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 threads = &account.collection.threads[&self.folder_hash];
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let thread = threads.thread_ref(thread_hash);
|
let thread = threads.thread_ref(thread_hash);
|
||||||
|
|
||||||
let fg_color = if thread.unseen() > 0 {
|
let fg_color = if thread.unseen() > 0 {
|
||||||
|
@ -404,10 +404,9 @@ impl ListingTrait for ConversationsListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
match account.search(&self.filter_term, self.sort, self.folder_hash) {
|
||||||
match account.search(&self.filter_term, self.sort, folder_hash) {
|
|
||||||
Ok(results) => {
|
Ok(results) => {
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
let threads = &account.collection.threads[&self.folder_hash];
|
||||||
for env_hash in results {
|
for env_hash in results {
|
||||||
if !account.collection.contains_key(&env_hash) {
|
if !account.collection.contains_key(&env_hash) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -495,6 +494,7 @@ impl ConversationsListing {
|
||||||
ConversationsListing {
|
ConversationsListing {
|
||||||
cursor_pos: (0, 1, 0),
|
cursor_pos: (0, 1, 0),
|
||||||
new_cursor_pos: (0, 0, 0),
|
new_cursor_pos: (0, 0, 0),
|
||||||
|
folder_hash: 0,
|
||||||
length: 0,
|
length: 0,
|
||||||
sort: (Default::default(), Default::default()),
|
sort: (Default::default(), Default::default()),
|
||||||
subsort: (SortField::Date, SortOrder::Desc),
|
subsort: (SortField::Date, SortOrder::Desc),
|
||||||
|
@ -524,11 +524,7 @@ impl ConversationsListing {
|
||||||
hash: ThreadHash,
|
hash: ThreadHash,
|
||||||
) -> EntryStrings {
|
) -> EntryStrings {
|
||||||
let thread = threads.thread_ref(hash);
|
let thread = threads.thread_ref(hash);
|
||||||
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
let folder = &context.accounts[self.cursor_pos.0].folder_confs[&self.folder_hash];
|
||||||
.unwrap()
|
|
||||||
.folder
|
|
||||||
.hash();
|
|
||||||
let folder = &context.accounts[self.cursor_pos.0].folder_confs[&folder_hash];
|
|
||||||
let mut tags = String::new();
|
let mut tags = String::new();
|
||||||
let mut colors = SmallVec::new();
|
let mut colors = SmallVec::new();
|
||||||
let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap();
|
let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap();
|
||||||
|
@ -605,7 +601,7 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
self.cursor_pos.1 = self.new_cursor_pos.1;
|
self.cursor_pos.1 = self.new_cursor_pos.1;
|
||||||
self.cursor_pos.0 = self.new_cursor_pos.0;
|
self.cursor_pos.0 = self.new_cursor_pos.0;
|
||||||
let folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
self.folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
||||||
.folders_order
|
.folders_order
|
||||||
.get(self.cursor_pos.1)
|
.get(self.cursor_pos.1)
|
||||||
{
|
{
|
||||||
|
@ -618,10 +614,11 @@ impl ConversationsListing {
|
||||||
|
|
||||||
// Get mailbox as a reference.
|
// Get mailbox as a reference.
|
||||||
//
|
//
|
||||||
match context.accounts[self.cursor_pos.0].status(folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string();
|
let message: String =
|
||||||
|
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
||||||
self.content =
|
self.content =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
|
@ -638,7 +635,7 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&folder_hash];
|
let threads = &context.accounts[self.cursor_pos.0].collection.threads[&self.folder_hash];
|
||||||
self.all_threads.clear();
|
self.all_threads.clear();
|
||||||
let mut roots = threads.roots();
|
let mut roots = threads.roots();
|
||||||
threads.group_inner_sort_by(
|
threads.group_inner_sort_by(
|
||||||
|
@ -898,9 +895,6 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash {
|
fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash {
|
||||||
//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];
|
|
||||||
if self.filter_term.is_empty() {
|
if self.filter_term.is_empty() {
|
||||||
*self
|
*self
|
||||||
.order
|
.order
|
||||||
|
@ -919,8 +913,7 @@ impl ConversationsListing {
|
||||||
|
|
||||||
fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) {
|
fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) {
|
||||||
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 threads = &account.collection.threads[&self.folder_hash];
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
let thread = threads.thread_ref(thread_hash);
|
let thread = threads.thread_ref(thread_hash);
|
||||||
let thread_node_hash = threads.thread_group_iter(thread_hash).next().unwrap().1;
|
let thread_node_hash = threads.thread_group_iter(thread_hash).next().unwrap().1;
|
||||||
let idx: usize = self.order[&thread_hash];
|
let idx: usize = self.order[&thread_hash];
|
||||||
|
@ -1202,8 +1195,7 @@ impl Component for ConversationsListing {
|
||||||
}
|
}
|
||||||
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
||||||
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 threads = &account.collection.threads[&self.folder_hash];
|
||||||
let threads = &account.collection.threads[&folder_hash];
|
|
||||||
if !account.collection.contains_key(&new_hash) {
|
if !account.collection.contains_key(&new_hash) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1228,7 +1220,7 @@ impl Component for ConversationsListing {
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
// FIXME subsort
|
// 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[&self.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);
|
||||||
//} else {
|
//} else {
|
||||||
// self.refresh_mailbox(context);
|
// self.refresh_mailbox(context);
|
||||||
|
@ -1241,13 +1233,8 @@ impl Component for ConversationsListing {
|
||||||
/*
|
/*
|
||||||
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]
|
|
||||||
[self.cursor_pos.1]
|
|
||||||
.unwrap()
|
|
||||||
.folder
|
|
||||||
.hash();
|
|
||||||
let threads = &context.accounts[self.cursor_pos.0].collection.threads
|
let threads = &context.accounts[self.cursor_pos.0].collection.threads
|
||||||
[&folder_hash];
|
[&self.folder_hash];
|
||||||
threads.vec_inner_sort_by(
|
threads.vec_inner_sort_by(
|
||||||
&mut self.filtered_selection,
|
&mut self.filtered_selection,
|
||||||
self.sort,
|
self.sort,
|
||||||
|
@ -1263,11 +1250,10 @@ impl Component for ConversationsListing {
|
||||||
Action::ToggleThreadSnooze if !self.unfocused => {
|
Action::ToggleThreadSnooze if !self.unfocused => {
|
||||||
let thread = 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();
|
|
||||||
account
|
account
|
||||||
.collection
|
.collection
|
||||||
.threads
|
.threads
|
||||||
.entry(folder_hash)
|
.entry(self.folder_hash)
|
||||||
.and_modify(|threads| {
|
.and_modify(|threads| {
|
||||||
let is_snoozed = threads.thread_ref(thread).snoozed();
|
let is_snoozed = threads.thread_ref(thread).snoozed();
|
||||||
threads.thread_ref_mut(thread).set_snoozed(!is_snoozed);
|
threads.thread_ref_mut(thread).set_snoozed(!is_snoozed);
|
||||||
|
@ -1283,22 +1269,12 @@ impl Component for ConversationsListing {
|
||||||
}
|
}
|
||||||
match *event {
|
match *event {
|
||||||
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
if (*idxa, *idxf) == (self.new_cursor_pos.0, self.folder_hash) =>
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| (*idxa, *idxf) == (self.new_cursor_pos.0, folder_hash))
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
{
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::StartupCheck(ref f)
|
UIEvent::StartupCheck(ref f) if *f == self.folder_hash => {
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| *f == folder_hash)
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ pub struct PlainListing {
|
||||||
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
||||||
cursor_pos: (usize, usize, usize),
|
cursor_pos: (usize, usize, usize),
|
||||||
new_cursor_pos: (usize, usize, usize),
|
new_cursor_pos: (usize, usize, usize),
|
||||||
|
folder_hash: FolderHash,
|
||||||
length: usize,
|
length: usize,
|
||||||
sort: (SortField, SortOrder),
|
sort: (SortField, SortOrder),
|
||||||
subsort: (SortField, SortOrder),
|
subsort: (SortField, SortOrder),
|
||||||
|
@ -401,8 +402,7 @@ impl ListingTrait for PlainListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
match account.search(&self.filter_term, self.sort, self.folder_hash) {
|
||||||
match account.search(&self.filter_term, self.sort, folder_hash) {
|
|
||||||
Ok(results) => {
|
Ok(results) => {
|
||||||
for env_hash in results {
|
for env_hash in results {
|
||||||
if !account.collection.contains_key(&env_hash) {
|
if !account.collection.contains_key(&env_hash) {
|
||||||
|
@ -476,6 +476,7 @@ impl PlainListing {
|
||||||
PlainListing {
|
PlainListing {
|
||||||
cursor_pos: (0, 1, 0),
|
cursor_pos: (0, 1, 0),
|
||||||
new_cursor_pos: (0, 0, 0),
|
new_cursor_pos: (0, 0, 0),
|
||||||
|
folder_hash: 0,
|
||||||
length: 0,
|
length: 0,
|
||||||
sort: (Default::default(), Default::default()),
|
sort: (Default::default(), Default::default()),
|
||||||
subsort: (SortField::Date, SortOrder::Desc),
|
subsort: (SortField::Date, SortOrder::Desc),
|
||||||
|
@ -500,11 +501,7 @@ impl PlainListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn make_entry_string(&self, e: EnvelopeRef, context: &Context) -> EntryStrings {
|
fn make_entry_string(&self, e: EnvelopeRef, context: &Context) -> EntryStrings {
|
||||||
let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1]
|
let folder = &context.accounts[self.cursor_pos.0].folder_confs[&self.folder_hash];
|
||||||
.unwrap()
|
|
||||||
.folder
|
|
||||||
.hash();
|
|
||||||
let folder = &context.accounts[self.cursor_pos.0].folder_confs[&folder_hash];
|
|
||||||
let mut tags = String::new();
|
let mut tags = String::new();
|
||||||
let mut colors = SmallVec::new();
|
let mut colors = SmallVec::new();
|
||||||
let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap();
|
let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap();
|
||||||
|
@ -563,7 +560,7 @@ impl PlainListing {
|
||||||
}
|
}
|
||||||
self.cursor_pos.1 = self.new_cursor_pos.1;
|
self.cursor_pos.1 = self.new_cursor_pos.1;
|
||||||
self.cursor_pos.0 = self.new_cursor_pos.0;
|
self.cursor_pos.0 = self.new_cursor_pos.0;
|
||||||
let folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
self.folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
||||||
.folders_order
|
.folders_order
|
||||||
.get(self.cursor_pos.1)
|
.get(self.cursor_pos.1)
|
||||||
{
|
{
|
||||||
|
@ -576,10 +573,11 @@ impl PlainListing {
|
||||||
|
|
||||||
// Get mailbox as a reference.
|
// Get mailbox as a reference.
|
||||||
//
|
//
|
||||||
match context.accounts[self.cursor_pos.0].status(folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string();
|
let message: String =
|
||||||
|
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
||||||
self.data_columns.columns[0] =
|
self.data_columns.columns[0] =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
|
@ -595,7 +593,7 @@ impl PlainListing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.local_collection = context.accounts[self.cursor_pos.0][folder_hash]
|
self.local_collection = context.accounts[self.cursor_pos.0][self.folder_hash]
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.envelopes
|
.envelopes
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -606,7 +604,7 @@ impl PlainListing {
|
||||||
.envelopes
|
.envelopes
|
||||||
.read()
|
.read()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.thread_node_hashes = context.accounts[self.cursor_pos.0][folder_hash]
|
self.thread_node_hashes = context.accounts[self.cursor_pos.0][self.folder_hash]
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.envelopes
|
.envelopes
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1056,7 +1054,7 @@ impl Component for PlainListing {
|
||||||
debug!("SubSort {:?} , {:?}", field, order);
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
//if !self.filtered_selection.is_empty() {
|
//if !self.filtered_selection.is_empty() {
|
||||||
// let threads = &account.collection.threads[&folder_hash];
|
// let threads = &account.collection.threads[&self.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);
|
||||||
//} else {
|
//} else {
|
||||||
// self.refresh_mailbox(context);
|
// self.refresh_mailbox(context);
|
||||||
|
@ -1107,30 +1105,22 @@ impl Component for PlainListing {
|
||||||
}
|
}
|
||||||
match *event {
|
match *event {
|
||||||
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
if (*idxa, *idxf) == (self.new_cursor_pos.0, self.folder_hash) =>
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| (*idxa, *idxf) == (self.new_cursor_pos.0, folder_hash))
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
{
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::StartupCheck(ref f)
|
UIEvent::StartupCheck(ref f) if *f == self.folder_hash => {
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| *f == folder_hash)
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
||||||
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();
|
|
||||||
if !account.collection.contains_key(new_hash)
|
if !account.collection.contains_key(new_hash)
|
||||||
|| !account[folder_hash].unwrap().envelopes.contains(new_hash)
|
|| !account[self.folder_hash]
|
||||||
|
.unwrap()
|
||||||
|
.envelopes
|
||||||
|
.contains(new_hash)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub struct ThreadListing {
|
||||||
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
/// (x, y, z): x is accounts, y is folders, z is index inside a folder.
|
||||||
cursor_pos: (usize, usize, usize),
|
cursor_pos: (usize, usize, usize),
|
||||||
new_cursor_pos: (usize, usize, usize),
|
new_cursor_pos: (usize, usize, usize),
|
||||||
|
folder_hash: FolderHash,
|
||||||
length: usize,
|
length: usize,
|
||||||
sort: (SortField, SortOrder),
|
sort: (SortField, SortOrder),
|
||||||
subsort: (SortField, SortOrder),
|
subsort: (SortField, SortOrder),
|
||||||
|
@ -238,6 +239,7 @@ impl ThreadListing {
|
||||||
ThreadListing {
|
ThreadListing {
|
||||||
cursor_pos: (0, 1, 0),
|
cursor_pos: (0, 1, 0),
|
||||||
new_cursor_pos: (0, 0, 0),
|
new_cursor_pos: (0, 0, 0),
|
||||||
|
folder_hash: 0,
|
||||||
length: 0,
|
length: 0,
|
||||||
sort: (Default::default(), Default::default()),
|
sort: (Default::default(), Default::default()),
|
||||||
subsort: (Default::default(), Default::default()),
|
subsort: (Default::default(), Default::default()),
|
||||||
|
@ -264,7 +266,7 @@ impl ThreadListing {
|
||||||
}
|
}
|
||||||
self.cursor_pos.1 = self.new_cursor_pos.1;
|
self.cursor_pos.1 = self.new_cursor_pos.1;
|
||||||
self.cursor_pos.0 = self.new_cursor_pos.0;
|
self.cursor_pos.0 = self.new_cursor_pos.0;
|
||||||
let folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
self.folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
||||||
.folders_order
|
.folders_order
|
||||||
.get(self.cursor_pos.1)
|
.get(self.cursor_pos.1)
|
||||||
{
|
{
|
||||||
|
@ -275,10 +277,11 @@ impl ThreadListing {
|
||||||
|
|
||||||
// Get mailbox as a reference.
|
// Get mailbox as a reference.
|
||||||
//
|
//
|
||||||
match context.accounts[self.cursor_pos.0].status(folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string();
|
let message: String =
|
||||||
|
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
||||||
self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' '));
|
self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' '));
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
|
@ -619,22 +622,12 @@ impl Component for ThreadListing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
UIEvent::MailboxUpdate((ref idxa, ref idxf))
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
if (*idxa, *idxf) == (self.new_cursor_pos.0, self.folder_hash) =>
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| (*idxa, *idxf) == (self.new_cursor_pos.0, folder_hash))
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
{
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::StartupCheck(ref f)
|
UIEvent::StartupCheck(ref f) if *f == self.folder_hash => {
|
||||||
if context.accounts[self.new_cursor_pos.0]
|
|
||||||
.folders_order
|
|
||||||
.get(self.new_cursor_pos.1)
|
|
||||||
.map(|&folder_hash| *f == folder_hash)
|
|
||||||
.unwrap_or(false) =>
|
|
||||||
{
|
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue