Commit a411c18fcc

a411c18fcc39f3e88ccb871c90dfb4cc49a6cc74

parent: 2f1a9a65ce

Unregistered key

vaw <git@nlih.de> · 2026-10-01 12:06 UTC
committer: <noreply@github.com>

Use the `via` parameter from space children to find rooms (#765)

Layout: unified · split

src/base.rs +1 −1
@@ -2371,7 +2371,7 @@ pub struct ChatStore {
2371 /// Cache of encountered `via` parameters in room links. 2371 /// Cache of encountered `via` parameters in room links.
2372 /// 2372 ///
2373 /// This is stored here because this data is lost in the conversion to [IambId]. 2373 /// This is stored here because this data is lost in the conversion to [IambId].
2374 pub room_via: HashMap<OwnedRoomOrAliasId, Vec<OwnedServerName>>, 2374 pub room_via: HashMap<OwnedRoomOrAliasId, HashSet<OwnedServerName>>,
2375 2375
2376 /// Map of joined spaces. 2376 /// Map of joined spaces.
2377 pub spaces: HashMap<OwnedRoomId, SpaceInfo>, 2377 pub spaces: HashMap<OwnedRoomId, SpaceInfo>,
src/config/mod.rs +7 −2
@@ -1,5 +1,6 @@
1//! # Logic for loading and validating application configuration 1//! # Logic for loading and validating application configuration
2 2
3use std::collections::HashSet;
3use std::env; 4use std::env;
4use std::fs::File; 5use std::fs::File;
5use std::io::{BufReader, BufWriter, Write as _}; 6use std::io::{BufReader, BufWriter, Write as _};
@@ -802,7 +803,7 @@ pub struct TunableValues {
802 pub message_user_color: bool, 803 pub message_user_color: bool,
803 pub default_register: Option<Register>, 804 pub default_register: Option<Register>,
804 pub default_room: Option<String>, 805 pub default_room: Option<String>,
805 pub default_via: Vec<OwnedServerName>, 806 pub default_via: HashSet<OwnedServerName>,
806 pub open_command: Option<Vec<String>>, 807 pub open_command: Option<Vec<String>>,
807 pub mouse: Mouse, 808 pub mouse: Mouse,
808 pub notifications: Notifications, 809 pub notifications: Notifications,
@@ -965,7 +966,11 @@ impl Tunables {
965 message_user_color: self.message_user_color.unwrap_or(false), 966 message_user_color: self.message_user_color.unwrap_or(false),
966 default_register: self.default_register, 967 default_register: self.default_register,
967 default_room: self.default_room, 968 default_room: self.default_room,
968 default_via: self.default_via.unwrap_or_else(|| vec![DEFAULT_VIA_SERVER.clone()]), 969 default_via: self
970 .default_via
971 .unwrap_or_else(|| vec![DEFAULT_VIA_SERVER.clone()])
972 .into_iter()
973 .collect(),
969 open_command: self.open_command, 974 open_command: self.open_command,
970 mouse: self.mouse.unwrap_or_default(), 975 mouse: self.mouse.unwrap_or_default(),
971 notifications: self.notifications.unwrap_or_default(), 976 notifications: self.notifications.unwrap_or_default(),
src/main.rs +6 −1
@@ -147,7 +147,12 @@ fn resolve_mxid(
147 }, 147 },
148 }; 148 };
149 149
150 store.application.room_via.insert(alias_id.to_owned(), via); 150 store
151 .application
152 .room_via
153 .entry(alias_id.to_owned())
154 .or_default()
155 .extend(via);
151 156
152 Ok(IambId::Room(alias_id, None)) 157 Ok(IambId::Room(alias_id, None))
153} 158}
src/tests.rs +1 −1
@@ -153,7 +153,7 @@ pub fn mock_tunables() -> TunableValues {
153 ignorecase: false, 153 ignorecase: false,
154 default_register: None, 154 default_register: None,
155 default_room: None, 155 default_room: None,
156 default_via: vec![], 156 default_via: Default::default(),
157 encryption: Encryption::default().values(), 157 encryption: Encryption::default().values(),
158 input_prompt: None, 158 input_prompt: None,
159 log_level: "warn".into(), 159 log_level: "warn".into(),
src/windows/room/not_joined.rs +3 −1
@@ -181,7 +181,9 @@ impl NotJoinedState {
181 .room_via 181 .room_via
182 .get(self.alias()) 182 .get(self.alias())
183 .unwrap_or(&store.application.settings.tunables.default_via) 183 .unwrap_or(&store.application.settings.tunables.default_via)
184 .to_vec(); 184 .iter()
185 .cloned()
186 .collect();
185 187
186 let chan = store.application.worker.join_room_chan(self.alias().to_owned(), via); 188 let chan = store.application.worker.join_room_chan(self.alias().to_owned(), via);
187 self.joining = Some(chan); 189 self.joining = Some(chan);
src/worker.rs +15 −3
@@ -271,7 +271,9 @@ async fn run_plan(client: &Client, store: &AsyncProgramStore, plan: Plan) {
271 .room_via 271 .room_via
272 .get(&alias_id) 272 .get(&alias_id)
273 .unwrap_or(&locked.application.settings.tunables.default_via) 273 .unwrap_or(&locked.application.settings.tunables.default_via)
274 .to_vec() 274 .iter()
275 .cloned()
276 .collect()
275 }; 277 };
276 278
277 let res = client.get_room_preview(&alias_id, via).await; 279 let res = client.get_room_preview(&alias_id, via).await;
@@ -993,11 +995,15 @@ async fn load_space_children(client: &Client, store: &AsyncProgramStore) {
993 } 995 }
994 996
995 let mut locked = store.lock().await; 997 let mut locked = store.lock().await;
998 let ChatStore { spaces, room_via, .. } = &mut locked.application;
999
996 for (room, ev) in all_events { 1000 for (room, ev) in all_events {
997 let room_id = room.room_id().to_owned(); 1001 let room_id = room.room_id().to_owned();
998 let info = locked.application.spaces.entry(room_id).or_default(); 1002 let info = spaces.entry(room_id.clone()).or_default();
999 match ev { 1003 match ev {
1000 SyncStateEvent::Original(ev) => { 1004 SyncStateEvent::Original(ev) => {
1005 room_via.entry(room_id.into()).or_default().extend(ev.content.via.clone());
1006
1001 info.children.insert(ev.state_key, (ev.content, ev.origin_server_ts)); 1007 info.children.insert(ev.state_key, (ev.content, ev.origin_server_ts));
1002 }, 1008 },
1003 SyncStateEvent::Redacted(ev) => { 1009 SyncStateEvent::Redacted(ev) => {
@@ -1601,10 +1607,16 @@ impl ClientWorker {
1601 async move { 1607 async move {
1602 let room_id = room.room_id().to_owned(); 1608 let room_id = room.room_id().to_owned();
1603 let mut locked = store.lock().await; 1609 let mut locked = store.lock().await;
1610 let ChatStore { spaces, room_via, .. } = &mut locked.application;
1604 1611
1605 let info = locked.application.spaces.entry(room_id).or_default(); 1612 let info = spaces.entry(room_id.clone()).or_default();
1606 match ev { 1613 match ev {
1607 SyncStateEvent::Original(ev) => { 1614 SyncStateEvent::Original(ev) => {
1615 room_via
1616 .entry(room_id.into())
1617 .or_default()
1618 .extend(ev.content.via.clone());
1619
1608 info.children.insert(ev.state_key, (ev.content, ev.origin_server_ts)); 1620 info.children.insert(ev.state_key, (ev.content, ev.origin_server_ts));
1609 }, 1621 },
1610 SyncStateEvent::Redacted(ev) => { 1622 SyncStateEvent::Redacted(ev) => {