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