summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-07-06 12:46:45 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-07-06 12:46:45 +0300
commita655a85b5fed4bb483044d09214e20186f343b9b (patch)
tree59517d53000ae3a2b7121db123cf4c70843d5ee0
parentb5ba9c3a8ca8f7a868adaac7e778a002f200bb4f (diff)
ui: fix replies not being synced and inserted properly on RefreshEvents
-rw-r--r--melib/src/collection.rs23
-rw-r--r--melib/src/thread.rs29
-rw-r--r--ui/src/components/mail/listing/compact.rs2
-rw-r--r--ui/src/conf/accounts.rs3
4 files changed, 27 insertions, 30 deletions
diff --git a/melib/src/collection.rs b/melib/src/collection.rs
index 3ae8c214..ba2a9d52 100644
--- a/melib/src/collection.rs
+++ b/melib/src/collection.rs
@@ -72,6 +72,12 @@ impl Collection {
.entry(folder_hash)
.or_default()
.remove(envelope_hash, &mut self.envelopes);
+ for (h, t) in self.threads.iter_mut() {
+ if *h == folder_hash {
+ continue;
+ }
+ t.remove(envelope_hash, &mut self.envelopes);
+ }
}
pub fn rename(
@@ -107,6 +113,14 @@ impl Collection {
.or_default()
.insert(&mut (*env), &self.envelopes);
}
+ for (h, t) in self.threads.iter_mut() {
+ if *h == folder_hash {
+ continue;
+ }
+ t.update_envelope(old_hash, new_hash, &self.envelopes)
+ .ok()
+ .take();
+ }
}
pub fn merge(
@@ -207,6 +221,14 @@ impl Collection {
.or_default()
.insert(&mut (*env), &self.envelopes);
}
+ for (h, t) in self.threads.iter_mut() {
+ if *h == folder_hash {
+ continue;
+ }
+ t.update_envelope(old_hash, new_hash, &self.envelopes)
+ .ok()
+ .take();
+ }
}
pub fn insert(&mut self, envelope: Envelope, folder_hash: FolderHash) -> &Envelope {
@@ -221,6 +243,7 @@ impl Collection {
&self.envelopes[&hash]
}
pub fn insert_reply(&mut self, env_hash: EnvelopeHash) {
+ debug_assert!(self.envelopes.contains_key(&env_hash));
for (_, t) in self.threads.iter_mut() {
t.insert_reply(&mut self.envelopes, env_hash);
}
diff --git a/melib/src/thread.rs b/melib/src/thread.rs
index c0e87cb9..9a97150e 100644
--- a/melib/src/thread.rs
+++ b/melib/src/thread.rs
@@ -1028,6 +1028,7 @@ impl Threads {
self.rebuild_thread(reply_to_id, envelopes);
true
} else {
+ /*
let new_id = ThreadHash::new();
self.thread_nodes.insert(
new_id,
@@ -1047,35 +1048,9 @@ impl Threads {
envelopes.get_mut(&env_hash).unwrap().set_thread(new_id);
self.hash_set.insert(env_hash);
self.rebuild_thread(new_id, envelopes);
+ */
false
}
- /*
- {
- if let Some(in_reply_to) = envelope.in_reply_to() {
- if !self.message_ids.contains_key(in_reply_to.raw()) {
- return false;
- }
- } else {
- return false;
- }
- }
- let hash: EnvelopeHash = envelope.hash();
- envelopes.insert(hash, envelope.clone());
- {
- let envelope = envelopes.entry(hash).or_default() as *mut Envelope;
- unsafe {
- /* Safe because insert only changes envelope's fields and nothing more */
- self.insert(&mut (*envelope), &envelopes);
- }
- }
- let envelope: &Envelope = &envelopes[&hash];
- {
- let in_reply_to = envelope.in_reply_to().unwrap().raw();
- let parent_id = self.message_ids[in_reply_to];
- self.rebuild_thread(parent_id, envelopes);
- }
- true
- */
}
/* Update thread tree information on envelope insertion */
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs
index 6514ca51..6bd5cb27 100644
--- a/ui/src/components/mail/listing/compact.rs
+++ b/ui/src/components/mail/listing/compact.rs
@@ -1121,7 +1121,7 @@ impl Component for CompactListing {
self.row_updates.push(*new_hash);
} else {
- /* Listing has was updated in time before the event */
+ /* Listing was updated in time before the event */
}
self.view
.process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context);
diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs
index 4fe63497..52cc9a24 100644
--- a/ui/src/conf/accounts.rs
+++ b/ui/src/conf/accounts.rs
@@ -315,6 +315,7 @@ impl Account {
let env_hash = envelope.hash();
let mailbox = mailbox!(&folder_hash, self.folders);
mailbox.insert(env_hash);
+ self.collection.insert(*envelope, folder_hash);
if self
.sent_folder
.as_ref()
@@ -322,8 +323,6 @@ impl Account {
.unwrap_or(false)
{
self.collection.insert_reply(env_hash);
- } else {
- self.collection.insert(*envelope, folder_hash);
}
let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders();