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