77 lines
3.2 KiB
Diff
77 lines
3.2 KiB
Diff
From 1546f95d8b6666a7f0e9575ddfa85bcb7ec53e3d Mon Sep 17 00:00:00 2001
|
|
From: Simon Gardling <titaniumtown@proton.me>
|
|
Date: Wed, 6 May 2026 14:38:07 -0400
|
|
Subject: [PATCH 6/7] fix(backend): Refresh cached channels on init_channels
|
|
re-runs
|
|
|
|
init_channels populates the channel cache via or_insert_with, then
|
|
hands every freshly-built Channel (orphan or just-inserted) to the
|
|
load_last + initialize_avatar pass. For the first-run case this is
|
|
fine because the freshly-built Channel is also the cached one. On
|
|
re-runs (Received::Contacts after the user adds a contact in another
|
|
client), the existing entry wins the cache and the freshly-built
|
|
Channel is dropped on the floor, but initialize_avatar still runs
|
|
on the orphan rather than the cached instance the UI is bound to.
|
|
|
|
The orphan's Contact gets its profile name and avatar populated;
|
|
the cached Contact does not, and the channel-list row is stuck on
|
|
"Unknown contact" until the next restart.
|
|
|
|
Use the result of `entry().or_insert_with()` so to_load contains
|
|
the actually-cached Channels.
|
|
---
|
|
src/backend/manager.rs | 28 +++++++++++++++++-----------
|
|
1 file changed, 17 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/src/backend/manager.rs b/src/backend/manager.rs
|
|
index 2e9bd761..38d355f4 100644
|
|
--- a/src/backend/manager.rs
|
|
+++ b/src/backend/manager.rs
|
|
@@ -625,13 +625,16 @@ impl Manager {
|
|
// Storing loaded cannels. Extra block around to drop `known_channels` before `await`.
|
|
{
|
|
let mut known_channels = self.imp().channels.borrow_mut();
|
|
- to_load.extend(loaded_channels.clone());
|
|
for channel in loaded_channels {
|
|
- known_channels.entry(channel.thread()).or_insert_with(|| {
|
|
- log::trace!("Got a contact from the storage");
|
|
- self.emit_by_name::<()>("channel", &[&channel]);
|
|
- channel
|
|
- });
|
|
+ let stored = known_channels
|
|
+ .entry(channel.thread())
|
|
+ .or_insert_with(|| {
|
|
+ log::trace!("Got a contact from the storage");
|
|
+ self.emit_by_name::<()>("channel", &[&channel]);
|
|
+ channel.clone()
|
|
+ })
|
|
+ .clone();
|
|
+ to_load.push(stored);
|
|
}
|
|
}
|
|
|
|
@@ -665,12 +668,15 @@ impl Manager {
|
|
// Store loaded channels. Extra block around to drop `known_channels` before `await`.
|
|
{
|
|
let mut known_channels = self.imp().channels.borrow_mut();
|
|
- to_load.extend(loaded_channels.clone());
|
|
for channel in loaded_channels {
|
|
- known_channels.entry(channel.thread()).or_insert_with(|| {
|
|
- self.emit_by_name::<()>("channel", &[&channel]);
|
|
- channel
|
|
- });
|
|
+ let stored = known_channels
|
|
+ .entry(channel.thread())
|
|
+ .or_insert_with(|| {
|
|
+ self.emit_by_name::<()>("channel", &[&channel]);
|
|
+ channel.clone()
|
|
+ })
|
|
+ .clone();
|
|
+ to_load.push(stored);
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.53.0
|
|
|