8000 fix(reader): load bodies a remembered conversation lacks by Dandiccf · Pull Request #461 · hyprlab/hylki · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

- **Fixed: a message from another folder stayed on "Loading…" in a
conversation.** A conversation is kept for a quick return, and one put
away before the body of a member from another folder (Archive, Sent)
came in kept that card empty: going back showed "Loading…" for good,
though the body was on disk. The missing bodies are filled in or asked
for again when the conversation is shown.

- **Changed: a reply sent from the reading pane becomes its card in the
conversation.** The editor lifts out of the composer and moves to where
the reply now sits in the conversation, turning into its card on the
Expand Down
23 changes: 22 additions & 1 deletion src/app.rs
8000
Original file line number Diff line number Diff line change
Expand Up @@ -6842,6 +6842,10 @@ impl SimpleComponent for AppModel {
tm.body = current.body.clone();
}
}
// A member whose body came after the conversation was
// put away (one from another folder, say) was stored
// without it, and would say "Loading…" for good.
self.load_missing_thread_bodies(Some((account_id, m.id)));
self.thread_painted = true;
self.thread_related_pending = false;
self.show_thread();
Expand Down Expand Up @@ -18689,6 +18693,9 @@ impl AppModel {
}
}
if added.is_empty() && retired.is_empty() {
// Nothing new, but a member may still lack its body: one the
// conversation was remembered without.
self.load_missing_thread_bodies(None);
return;
}
conv.extend(added);
Expand All @@ -18697,10 +18704,24 @@ impl AppModel {
// period so they join the first paint instead of causing a second.
self.thread_opened_at = Some(std::time::Instant::now());
self.current_thread = conv;
self.load_missing_thread_bodies(None);
}

/// Give every member of the conversation on screen that has no body the
/// one the app already holds, and ask the workers for the rest. `except`
/// is a member whose body is already on its way by another request.
fn load_missing_thread_bodies(&mut self, except: Option<(u32, u32)>) {
for tm in self.current_thread.iter_mut() {
if tm.body.is_empty() {
if let Some(b) = self.body_cache.get(&body_key(tm)) {
tm.body = b.clone();
}
}
}
let to_load: Vec<MissingBody> = self
.current_thread
.iter()
.filter(|tm| tm.body.is_empty())
.filter(|tm| tm.body.is_empty() && except != Some((tm.account_id, tm.id)))
.filter_map(|tm| self.resolve_folder_path(tm).map(|p| (tm.account_id, tm.id, tm.uid, p)))
.collect();
for ((aid, path), items) in batch_bodies_by_folder(to_load) {
Expand Down
0