Add various logic checks
parent
6ca8c3b964
commit
a8c1016f37
|
@ -827,6 +827,7 @@ impl ImapType {
|
|||
debug!("parse error for {:?}", l);
|
||||
}
|
||||
}
|
||||
mailboxes.retain(|_, v| v.hash != 0);
|
||||
conn.send_command(b"LSUB \"\" \"*\"")?;
|
||||
conn.read_response(&mut res)?;
|
||||
debug!("out: {}", &res);
|
||||
|
|
|
@ -350,8 +350,13 @@ impl Collection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, envelope: Envelope, mailbox_hash: MailboxHash) {
|
||||
pub fn insert(&mut self, envelope: Envelope, mailbox_hash: MailboxHash) -> bool {
|
||||
let hash = envelope.hash();
|
||||
if self.message_ids.contains_key(envelope.message_id().raw()) {
|
||||
/* Duplicate. For example could be same message sent to two mailing lists and we get
|
||||
* it twice */
|
||||
return true;
|
||||
};
|
||||
self.mailboxes.entry(mailbox_hash).and_modify(|m| {
|
||||
m.insert(hash);
|
||||
});
|
||||
|
@ -369,6 +374,7 @@ impl Collection {
|
|||
{
|
||||
self.insert_reply(hash);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn insert_reply(&mut self, env_hash: EnvelopeHash) {
|
||||
|
|
|
@ -679,6 +679,13 @@ impl Threads {
|
|||
.message_ids
|
||||
.get(message_id)
|
||||
.cloned()
|
||||
.or(
|
||||
if envelopes_lck[&env_hash].thread() != ThreadNodeHash::null() {
|
||||
Some(envelopes_lck[&env_hash].thread())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
)
|
||||
.unwrap_or_else(|| ThreadNodeHash::new());
|
||||
{
|
||||
let mut node = self.thread_nodes.entry(new_id).or_default();
|
||||
|
|
10
src/bin.rs
10
src/bin.rs
|
@ -97,11 +97,15 @@ fn notify(
|
|||
signals: &[c_int],
|
||||
sender: crossbeam::channel::Sender<ThreadEvent>,
|
||||
) -> std::result::Result<crossbeam::channel::Receiver<c_int>, std::io::Error> {
|
||||
use std::time::Duration;
|
||||
let alarm_sender = sender.clone();
|
||||
let alarm_handler = move |info: &nix::libc::siginfo_t| {
|
||||
let value = unsafe { info.si_value().sival_ptr as u8 };
|
||||
alarm_sender
|
||||
.send(ThreadEvent::UIEvent(UIEvent::Timer(value)))
|
||||
.send_timeout(
|
||||
ThreadEvent::UIEvent(UIEvent::Timer(value)),
|
||||
Duration::from_millis(500),
|
||||
)
|
||||
.unwrap();
|
||||
};
|
||||
unsafe {
|
||||
|
@ -114,11 +118,11 @@ fn notify(
|
|||
loop {
|
||||
ctr %= 3;
|
||||
if ctr == 0 {
|
||||
sender.send(ThreadEvent::Pulse).unwrap();
|
||||
sender.send_timeout(ThreadEvent::Pulse, Duration::from_millis(500));
|
||||
}
|
||||
|
||||
for signal in signals.pending() {
|
||||
s.send(signal).unwrap();
|
||||
s.send_timeout(signal, Duration::from_millis(500)).unwrap();
|
||||
}
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
|
|
|
@ -647,6 +647,7 @@ impl ThreadView {
|
|||
|
||||
/* First draw the thread subject on the first row */
|
||||
let y = if self.dirty {
|
||||
clear_area(grid, area, crate::conf::value(context, "theme_default"));
|
||||
let account = &context.accounts[self.coordinates.0];
|
||||
let threads = &account.collection.threads[&self.coordinates.1];
|
||||
let thread_root = threads
|
||||
|
@ -749,6 +750,7 @@ impl ThreadView {
|
|||
|
||||
/* First draw the thread subject on the first row */
|
||||
let y = {
|
||||
clear_area(grid, area, crate::conf::value(context, "theme_default"));
|
||||
let account = &context.accounts[self.coordinates.0];
|
||||
let threads = &account.collection.threads[&self.coordinates.1];
|
||||
let thread_root = threads
|
||||
|
|
|
@ -327,7 +327,6 @@ impl Account {
|
|||
}
|
||||
|
||||
let mut tree: Vec<MailboxNode> = Vec::new();
|
||||
let mut collection: Collection = Collection::new(Default::default());
|
||||
for (h, f) in ref_mailboxes.iter() {
|
||||
if !f.is_subscribed() {
|
||||
/* Skip unsubscribed mailbox */
|
||||
|
@ -344,7 +343,7 @@ impl Account {
|
|||
);
|
||||
}
|
||||
});
|
||||
collection.new_mailbox(*h);
|
||||
self.collection.new_mailbox(*h);
|
||||
}
|
||||
|
||||
build_mailboxes_order(&mut tree, &mailbox_entries, &mut mailboxes_order);
|
||||
|
@ -352,7 +351,6 @@ impl Account {
|
|||
self.mailbox_entries = mailbox_entries;
|
||||
self.tree = tree;
|
||||
self.sent_mailbox = sent_mailbox;
|
||||
self.collection = collection;
|
||||
}
|
||||
|
||||
fn new_worker(
|
||||
|
@ -536,7 +534,11 @@ impl Account {
|
|||
);
|
||||
}
|
||||
}
|
||||
self.collection.insert(*envelope, mailbox_hash);
|
||||
|
||||
if self.collection.insert(*envelope, mailbox_hash) {
|
||||
/* is a duplicate */
|
||||
return None;
|
||||
}
|
||||
|
||||
if self.mailbox_entries[&mailbox_hash]
|
||||
.conf
|
||||
|
|
|
@ -1707,6 +1707,7 @@ pub fn write_string_to_grid(
|
|||
}
|
||||
}
|
||||
for c in s.chars() {
|
||||
inspect_bounds!(grid, area, x, y, line_break);
|
||||
if c == '\r' {
|
||||
continue;
|
||||
}
|
||||
|
@ -1753,8 +1754,6 @@ pub fn write_string_to_grid(
|
|||
_ => {}
|
||||
}
|
||||
x += 1;
|
||||
|
||||
inspect_bounds!(grid, area, x, y, line_break);
|
||||
}
|
||||
(x, y)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue