ui: fix replies not being synced and inserted properly on RefreshEvents

embed
Manos Pitsidianakis 2019-07-06 12:46:45 +03:00
parent b5ba9c3a8c
commit a655a85b5f
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 27 additions and 30 deletions

View File

@ -72,6 +72,12 @@ impl Collection {
.entry(folder_hash) .entry(folder_hash)
.or_default() .or_default()
.remove(envelope_hash, &mut self.envelopes); .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( pub fn rename(
@ -107,6 +113,14 @@ impl Collection {
.or_default() .or_default()
.insert(&mut (*env), &self.envelopes); .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( pub fn merge(
@ -207,6 +221,14 @@ impl Collection {
.or_default() .or_default()
.insert(&mut (*env), &self.envelopes); .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 { pub fn insert(&mut self, envelope: Envelope, folder_hash: FolderHash) -> &Envelope {
@ -221,6 +243,7 @@ impl Collection {
&self.envelopes[&hash] &self.envelopes[&hash]
} }
pub fn insert_reply(&mut self, env_hash: EnvelopeHash) { pub fn insert_reply(&mut self, env_hash: EnvelopeHash) {
debug_assert!(self.envelopes.contains_key(&env_hash));
for (_, t) in self.threads.iter_mut() { for (_, t) in self.threads.iter_mut() {
t.insert_reply(&mut self.envelopes, env_hash); t.insert_reply(&mut self.envelopes, env_hash);
} }

View File

@ -1028,6 +1028,7 @@ impl Threads {
self.rebuild_thread(reply_to_id, envelopes); self.rebuild_thread(reply_to_id, envelopes);
true true
} else { } else {
/*
let new_id = ThreadHash::new(); let new_id = ThreadHash::new();
self.thread_nodes.insert( self.thread_nodes.insert(
new_id, new_id,
@ -1047,35 +1048,9 @@ impl Threads {
envelopes.get_mut(&env_hash).unwrap().set_thread(new_id); envelopes.get_mut(&env_hash).unwrap().set_thread(new_id);
self.hash_set.insert(env_hash); self.hash_set.insert(env_hash);
self.rebuild_thread(new_id, envelopes); self.rebuild_thread(new_id, envelopes);
*/
false 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 */ /* Update thread tree information on envelope insertion */

View File

@ -1121,7 +1121,7 @@ impl Component for CompactListing {
self.row_updates.push(*new_hash); self.row_updates.push(*new_hash);
} else { } else {
/* Listing has was updated in time before the event */ /* Listing was updated in time before the event */
} }
self.view self.view
.process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context);

View File

@ -315,6 +315,7 @@ impl Account {
let env_hash = envelope.hash(); let env_hash = envelope.hash();
let mailbox = mailbox!(&folder_hash, self.folders); let mailbox = mailbox!(&folder_hash, self.folders);
mailbox.insert(env_hash); mailbox.insert(env_hash);
self.collection.insert(*envelope, folder_hash);
if self if self
.sent_folder .sent_folder
.as_ref() .as_ref()
@ -322,8 +323,6 @@ impl Account {
.unwrap_or(false) .unwrap_or(false)
{ {
self.collection.insert_reply(env_hash); self.collection.insert_reply(env_hash);
} else {
self.collection.insert(*envelope, folder_hash);
} }
let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders(); let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders();