Browse Source

Remove unused variables/functions

tags/alpha-0.6.0
Manos Pitsidianakis 3 months ago
parent
commit
99fbac3806
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
7 changed files with 24 additions and 72 deletions
  1. +0
    -2
      melib/src/collection.rs
  2. +1
    -3
      src/components/contacts/contact_list.rs
  3. +4
    -9
      src/components/mail/listing/compact.rs
  4. +5
    -8
      src/components/mail/listing/plain.rs
  5. +12
    -48
      src/components/mail/listing/thread.rs
  6. +1
    -1
      src/conf/accounts.rs
  7. +1
    -1
      src/plugins/backend.rs

+ 0
- 2
melib/src/collection.rs View File

@ -21,7 +21,6 @@
use super::*;
use crate::backends::MailboxHash;
use core::ops::{Index, IndexMut};
use smallvec::SmallVec;
use std::ops::{Deref, DerefMut};
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
@ -490,7 +489,6 @@ impl Collection {
}
}
pub struct RwRef<'g, K: std::cmp::Eq + std::hash::Hash, V> {
guard: RwLockReadGuard<'g, HashMap<K, V>>,
hash: K,

+ 1
- 3
src/components/contacts/contact_list.rs View File

@ -24,8 +24,6 @@ use crate::melib::text_processing::TextProcessing;
use melib::CardId;
use std::cmp;
const MAX_COLS: usize = 500;
#[derive(Debug, PartialEq)]
enum ViewMode {
List,
@ -220,7 +218,7 @@ impl ContactList {
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
((0, 0), (MAX_COLS - 1, 0)),
((0, 0), (message.len() - 1, 0)),
None,
);
return;

+ 4
- 9
src/components/mail/listing/compact.rs View File

@ -27,8 +27,6 @@ use std::cmp;
use std::convert::TryInto;
use std::iter::FromIterator;
const MAX_COLS: usize = 500;
macro_rules! address_list {
(($name:expr) as comma_sep_list) => {{
let mut ret: String =
@ -240,7 +238,7 @@ impl MailListingTrait for CompactListing {
self.color_cache.theme_default.fg,
self.color_cache.theme_default.bg,
self.color_cache.theme_default.attrs,
((0, 0), (MAX_COLS - 1, 0)),
((0, 0), (message.len() - 1, 0)),
None,
);
return;
@ -435,7 +433,7 @@ impl MailListingTrait for CompactListing {
self.color_cache.theme_default.fg,
self.color_cache.theme_default.bg,
self.color_cache.theme_default.attrs,
((0, 0), (MAX_COLS - 1, 0)),
((0, 0), (message.len() - 1, 0)),
None,
);
}
@ -1337,13 +1335,10 @@ impl CompactListing {
"Encountered an error while searching for `{}`: {}.",
search_term, err
);
log(
format!("Failed to search for term {}: {}", search_term, err),
ERROR,
);
log(message.clone(), ERROR);
context.replies.push_back(UIEvent::Notification(
Some("Could not perform search".to_string()),
err.to_string(),
message,
Some(crate::types::NotificationType::ERROR),
));
}

+ 5
- 8
src/components/mail/listing/plain.rs View File

@ -26,8 +26,6 @@ use crate::jobs::{oneshot, JobId, JoinHandle};
use std::cmp;
use std::iter::FromIterator;
const MAX_COLS: usize = 500;
macro_rules! address_list {
(($name:expr) as comma_sep_list) => {{
let mut ret: String =
@ -163,7 +161,7 @@ impl MailListingTrait for PlainListing {
self.color_cache.theme_default.fg,
self.color_cache.theme_default.bg,
self.color_cache.theme_default.attrs,
((0, 0), (MAX_COLS - 1, 0)),
((0, 0), (message.len().saturating_sub(1), 0)),
None,
);
return;
@ -982,7 +980,7 @@ impl PlainListing {
self.color_cache.theme_default.fg,
self.color_cache.theme_default.bg,
self.color_cache.theme_default.attrs,
((0, 0), (MAX_COLS - 1, 0)),
((0, 0), (message.len() - 1, 0)),
None,
);
}
@ -1296,10 +1294,9 @@ impl Component for PlainListing {
let (chan, handle, job_id) = context.accounts[self.cursor_pos.0]
.job_executor
.spawn_specialized(job);
context.accounts[self.cursor_pos.0].active_jobs.insert(
job_id,
crate::conf::accounts::JobRequest::Search(handle),
);
context.accounts[self.cursor_pos.0]
.active_jobs
.insert(job_id, crate::conf::accounts::JobRequest::Search(handle));
self.search_job = Some((filter_term.to_string(), chan, job_id));
}
Err(err) => {

+ 12
- 48
src/components/mail/listing/thread.rs View File

@ -24,8 +24,6 @@ use crate::components::utilities::PageMovement;
use std::cmp;
use std::convert::TryInto;
const MAX_COLS: usize = 500;
/// A list of all mail (`Envelope`s) in a `Mailbox`. On `\n` it opens the `Envelope` content in a
/// `MailView`.
#[derive(Debug)]
@ -106,18 +104,18 @@ impl MailListingTrait for ThreadListing {
};
let message: String =
context.accounts[self.cursor_pos.0][&self.cursor_pos.1].status();
self.data_columns.columns[0] =
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
self.length = 0;
/*
write_string_to_grid(
message.as_str(),
&mut self.content,
&mut self.data_columns.columns[0],
self.color_cache.theme_default.fg,
self.color_cache.theme_default.bg,
self.color_cache.theme_default.attrs,
((0, 0), (MAX_COLS - 1, 0)),
((0, 0), (message.len().saturating_sub(1), 0)),
None,
);
*/
return;
}
}
@ -155,18 +153,17 @@ impl MailListingTrait for ThreadListing {
};
if threads.len() == 0 {
let message = format!("Mailbox `{}` is empty.", account[&self.cursor_pos.1].name());
/*
class="bp">self class="p">. class="n">content = CellBuffer::new_with_context(message.len(), 1, default_cell, context);
self.data_columns.columns[0] =
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
write_string_to_grid(
&message,
&mut self.content,
message.as_str(),
&mut self.data_columns.columns[0],
self.color_cache.theme_default.fg,
self.color_cache.theme_default.bg,
self.color_cache.theme_default.attrs,
((0, 0), (message.len() - 1, 0)),
None,
);
*/
return;
}
let mut rows = Vec::with_capacity(1024);
@ -186,9 +183,6 @@ impl MailListingTrait for ThreadListing {
);
let mut indentations: Vec<bool> = Vec::with_capacity(6);
let mut thread_idx = 0; // needed for alternate thread colors
/* Draw threaded view. */
let roots = items
.filter_map(|r| threads.groups[&r].root().map(|r| r.root))
.collect::<_>();
@ -200,9 +194,6 @@ impl MailListingTrait for ThreadListing {
while let Some((indentation, thread_node_hash, has_sibling)) = iter.next() {
let thread_node = &thread_nodes[&thread_node_hash];
if indentation == 0 {
thread_idx += 1;
}
if thread_node.has_message() {
let envelope: EnvelopeRef =
account.collection.get_env(thread_node.message().unwrap());
@ -225,7 +216,6 @@ impl MailListingTrait for ThreadListing {
let mut entry_strings = self.make_entry_string(&envelope, context);
entry_strings.subject = SubjectString(ThreadListing::make_thread_entry(
&envelope,
idx,
indentation,
thread_node_hash,
&threads,
@ -693,7 +683,9 @@ impl ThreadListing {
}
}
fn highlight_line_self(&mut self, idx: usize, context: &Context) {
fn highlight_line_self(&mut self, _idx: usize, _context: &Context) {
/*
* FIXME
if self.length == 0 {
return;
}
@ -703,23 +695,11 @@ impl ThreadListing {
.collection
.get_env(env_hash);
let fg_color = if !envelope.is_seen() {
Color::Byte(0)
} else {
Color::Default
};
let bg_color = if !envelope.is_seen() {
Color::Byte(251)
} else if idx % 2 == 0 {
Color::Byte(236)
} else {
Color::Default
};
*/
}
fn make_thread_entry(
envelope: &Envelope,
idx: usize,
indent: usize,
node_idx: ThreadNodeHash,
threads: &Threads,
@ -779,21 +759,6 @@ impl ThreadListing {
.0
}
fn format_date(envelope: &Envelope) -> String {
let d = std::time::UNIX_EPOCH + std::time::Duration::from_secs(envelope.date());
let now: std::time::Duration = std::time::SystemTime::now()
.duration_since(d)
.unwrap_or_else(|_| std::time::Duration::new(std::u64::MAX, 0));
match now.as_secs() {
n if n < 10 * 60 * 60 => format!("{} hours ago{}", n / (60 * 60), " ".repeat(8)),
n if n < 24 * 60 * 60 => format!("{} hours ago{}", n / (60 * 60), " ".repeat(7)),
n if n < 4 * 24 * 60 * 60 => {
format!("{} days ago{}", n / (24 * 60 * 60), " ".repeat(9))
}
_ => melib::datetime::timestamp_to_string(envelope.datetime(), None),
}
}
fn make_entry_string(&self, e: &Envelope, context: &Context) -> EntryStrings {
let mut tags = String::new();
let mut colors: SmallVec<[_; 8]> = SmallVec::new();
@ -855,7 +820,6 @@ impl ThreadListing {
self.data_columns.columns[3].size().0,
self.data_columns.columns[4].size().0,
);
let account = &context.accounts[self.cursor_pos.0];
for ((idx, is_seen, has_attachments, env_hash), strings) in
self.rows.iter().skip(start).take(end - start + 1)

+ 1
- 1
src/conf/accounts.rs View File

@ -33,7 +33,7 @@ use melib::backends::{
use melib::email::*;
use melib::error::{MeliError, Result};
use melib::text_processing::GlobMatch;
use melib::thread::{SortField, SortOrder, ThreadNode, ThreadNodeHash, Threads};
use melib::thread::{SortField, SortOrder, Threads};
use melib::AddressBook;
use melib::Collection;
use smallvec::SmallVec;

+ 1
- 1
src/plugins/backend.rs View File

@ -98,7 +98,7 @@ impl MailBackend for PluginBackend {
}
}
fn fetch(&mut self, mailbox_hash: MailboxHash) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, _mailbox_hash: MailboxHash) -> Result<Async<Result<Vec<Envelope>>>> {
let mut w = AsyncBuilder::new();
let channel = self.channel.clone();
let handle = {

Loading…
Cancel
Save