Commit 0bbdb31e92
Unregistered key
Layout: unified · split
Cargo.lock +10 −10
| @@ -1622,9 +1622,9 @@ dependencies = [ | ||
| 1622 | 1622 | |
| 1623 | 1623 | [[package]] |
| 1624 | 1624 | name = "editor-types" |
| 1625 | version = "0.0.6" | |
| 1625 | version = "0.0.7" | |
| 1626 | 1626 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1627 | checksum = "687ec495f9b4b64810edb5ce1ef7166e79e7cec40bc5ab961d9dcde895e97e4b" | |
| 1627 | checksum = "f674ce4e9257322235aba6dfef5001601a392d4d6a55ce5fee0b2f6ccc59f939" | |
| 1628 | 1628 | dependencies = [ |
| 1629 | 1629 | "anyhow", |
| 1630 | 1630 | "bitflags 2.13.2", |
| @@ -1637,9 +1637,9 @@ dependencies = [ | ||
| 1637 | 1637 | |
| 1638 | 1638 | [[package]] |
| 1639 | 1639 | name = "editor-types-macros" |
| 1640 | version = "0.0.6" | |
| 1640 | version = "0.0.7" | |
| 1641 | 1641 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1642 | checksum = "7b5930990ea80a57334a6999d086d2df28a5b67748c32479f0cb1cca8c5d9461" | |
| 1642 | checksum = "edea356fa2bc1811afa475bdcca520fcfbdd364da11b1aaa98a8a959d19fa599" | |
| 1643 | 1643 | dependencies = [ |
| 1644 | 1644 | "editor-types-parser", |
| 1645 | 1645 | "proc-macro2", |
| @@ -1649,9 +1649,9 @@ dependencies = [ | ||
| 1649 | 1649 | |
| 1650 | 1650 | [[package]] |
| 1651 | 1651 | name = "editor-types-parser" |
| 1652 | version = "0.0.6" | |
| 1652 | version = "0.0.7" | |
| 1653 | 1653 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1654 | checksum = "86caf8408696409d3d6f58c1165ecc21a39effb55cb5c708742cc0c12f18e7eb" | |
| 1654 | checksum = "866198f9356c6a256e272da4ff2c8305c0f2e2d5608a6e0e0b1416e67e1cca9e" | |
| 1655 | 1655 | dependencies = [ |
| 1656 | 1656 | "logos", |
| 1657 | 1657 | "pomelo", |
| @@ -3852,9 +3852,9 @@ dependencies = [ | ||
| 3852 | 3852 | |
| 3853 | 3853 | [[package]] |
| 3854 | 3854 | name = "modalkit" |
| 3855 | version = "0.0.31" | |
| 3855 | version = "0.0.32" | |
| 3856 | 3856 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3857 | checksum = "8b83364f3f8da5c3b42911179519ac7dafed42ff09b5be31d2f68ffb6732f287" | |
| 3857 | checksum = "7b65714e623849687ac7730864ca2e5ec08265f0e4666bb51a23c8ebe604cfce" | |
| 3858 | 3858 | dependencies = [ |
| 3859 | 3859 | "anyhow", |
| 3860 | 3860 | "anymap2", |
| @@ -3877,9 +3877,9 @@ dependencies = [ | ||
| 3877 | 3877 | |
| 3878 | 3878 | [[package]] |
| 3879 | 3879 | name = "modalkit-ratatui" |
| 3880 | version = "0.0.31" | |
| 3880 | version = "0.0.32" | |
| 3881 | 3881 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3882 | checksum = "b98b10507e0a800195aa26e1d1ff85a68fdfa4a91961456f7d803e1453885e12" | |
| 3882 | checksum = "40ef715586403fb4ff1fccf77ef0742940d39abe24bf5f653a2586376edaefc6" | |
| 3883 | 3883 | dependencies = [ |
| 3884 | 3884 | "crossterm 0.29.0", |
| 3885 | 3885 | "enum-map", |
Cargo.toml +2 −2
| @@ -84,13 +84,13 @@ version = "4.12" | ||
| 84 | 84 | optional = true |
| 85 | 85 | |
| 86 | 86 | [dependencies.modalkit] |
| 87 | version = "0.0.31" | |
| 87 | version = "0.0.32" | |
| 88 | 88 | default-features = false |
| 89 | 89 | #git = "https://github.com/ulyssa/modalkit" |
| 90 | 90 | #rev = "31158b7b759ef6f4b3c0d56305fa8a68365d8a96" |
| 91 | 91 | |
| 92 | 92 | [dependencies.modalkit-ratatui] |
| 93 | version = "0.0.31" | |
| 93 | version = "0.0.32" | |
| 94 | 94 | #git = "https://github.com/ulyssa/modalkit" |
| 95 | 95 | #rev = "31158b7b759ef6f4b3c0d56305fa8a68365d8a96" |
| 96 | 96 | |
src/commands.rs +8 −5
| @@ -705,7 +705,8 @@ fn iamb_join(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 705 | 705 | return Ok(step); |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | let open = ctx.switch(args.remove(0)); | |
| 708 | let flags = OpenFlags::FORCE; | |
| 709 | let open = ctx.with_open_flags(flags).switch(args.remove(0)); | |
| 709 | 710 | let step = CommandStep::Continue(open, ctx.context.clone()); |
| 710 | 711 | |
| 711 | 712 | return Ok(step); |
| @@ -1368,7 +1369,7 @@ mod tests { | ||
| 1368 | 1369 | |
| 1369 | 1370 | let mut cmds = setup_commands(&aliases).unwrap(); |
| 1370 | 1371 | |
| 1371 | let act = WindowAction::Switch(OpenTarget::Application(IambId::ChatList)); | |
| 1372 | let act = WindowAction::Switch(OpenTarget::Application(IambId::ChatList), OpenFlags::NONE); | |
| 1372 | 1373 | let expected = vec![(act.into(), ctx.clone())]; |
| 1373 | 1374 | |
| 1374 | 1375 | assert_eq!(cmds.input_cmd("c", ctx.clone()).unwrap(), expected); |
| @@ -1381,7 +1382,8 @@ mod tests { | ||
| 1381 | 1382 | let ctx = EditContext::default(); |
| 1382 | 1383 | |
| 1383 | 1384 | let res = cmds.input_cmd(":verify", ctx.clone()).unwrap(); |
| 1384 | let act = WindowAction::Switch(OpenTarget::Application(IambId::VerifyList)); | |
| 1385 | let act = | |
| 1386 | WindowAction::Switch(OpenTarget::Application(IambId::VerifyList), OpenFlags::NONE); | |
| 1385 | 1387 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| 1386 | 1388 | |
| 1387 | 1389 | let res = cmds.input_cmd(":verify request @user1:example.com", ctx.clone()).unwrap(); |
| @@ -1439,11 +1441,12 @@ mod tests { | ||
| 1439 | 1441 | let ctx = EditContext::default(); |
| 1440 | 1442 | |
| 1441 | 1443 | let res = cmds.input_cmd("join #foobar:example.com", ctx.clone()).unwrap(); |
| 1442 | let act = WindowAction::Switch(OpenTarget::Name("#foobar:example.com".into())); | |
| 1444 | let act = | |
| 1445 | WindowAction::Switch(OpenTarget::Name("#foobar:example.com".into()), OpenFlags::FORCE); | |
| 1443 | 1446 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| 1444 | 1447 | |
| 1445 | 1448 | let res = cmds.input_cmd("join #", ctx.clone()).unwrap(); |
| 1446 | let act = WindowAction::Switch(OpenTarget::Alternate); | |
| 1449 | let act = WindowAction::Switch(OpenTarget::Alternate, OpenFlags::FORCE); | |
| 1447 | 1450 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| 1448 | 1451 | |
| 1449 | 1452 | let res = cmds.input_cmd("join", ctx.clone()).unwrap(); |
src/main.rs +6 −6
| @@ -178,7 +178,7 @@ fn setup_screen( | ||
| 178 | 178 | if let Some((id, via)) = initial_room { |
| 179 | 179 | match resolve_mxid(store, id, via) { |
| 180 | 180 | Ok(id) => { |
| 181 | return Ok(ScreenState::new(IambWindow::open(id, store)?, cmd)); | |
| 181 | return Ok(ScreenState::new(IambWindow::open(id, OpenFlags::NONE, store)?, cmd)); | |
| 182 | 182 | }, |
| 183 | 183 | Err(err) => { |
| 184 | 184 | store.application.draw_error = Some(format!("layout restore: {err}")); |
| @@ -215,8 +215,8 @@ fn setup_screen( | ||
| 215 | 215 | let win = settings |
| 216 | 216 | .tunables |
| 217 | 217 | .default_room |
| 218 | .and_then(|room| IambWindow::find(room, store).ok()) | |
| 219 | .or_else(|| IambWindow::open(IambId::Welcome, store).ok()) | |
| 218 | .and_then(|room| IambWindow::find(room, OpenFlags::NONE, store).ok()) | |
| 219 | .or_else(|| IambWindow::open(IambId::Welcome, OpenFlags::NONE, store).ok()) | |
| 220 | 220 | .unwrap(); |
| 221 | 221 | |
| 222 | 222 | return Ok(ScreenState::new(win, cmd)); |
| @@ -486,7 +486,7 @@ impl Application { | ||
| 486 | 486 | // Switch to the right window. |
| 487 | 487 | if let Some(winid) = content.to_window() { |
| 488 | 488 | let open = OpenTarget::Application(winid); |
| 489 | let open = WindowAction::Switch(open); | |
| 489 | let open = WindowAction::Switch(open, OpenFlags::NONE); | |
| 490 | 490 | let _ = self.screen.window_command(&open, &ctx, store)?; |
| 491 | 491 | |
| 492 | 492 | // Run command again. |
| @@ -664,7 +664,7 @@ impl Application { | ||
| 664 | 664 | match resolve_mxid(store, id.to_owned(), via.to_vec()) { |
| 665 | 665 | Ok(id) => { |
| 666 | 666 | let target = OpenTarget::Application(id); |
| 667 | let action = WindowAction::Switch(target); | |
| 667 | let action = WindowAction::Switch(target, OpenFlags::NONE); | |
| 668 | 668 | |
| 669 | 669 | self.action_prepend(vec![(action.into(), ctx)]); |
| 670 | 670 | None |
| @@ -708,7 +708,7 @@ impl Application { | ||
| 708 | 708 | let room_id = create_room(client, alias, vis, flags).await?; |
| 709 | 709 | let room = IambId::Room(room_id.into(), RoomView::Main); |
| 710 | 710 | let target = OpenTarget::Application(room); |
| 711 | let action = WindowAction::Switch(target); | |
| 711 | let action = WindowAction::Switch(target, OpenFlags::NONE); | |
| 712 | 712 | |
| 713 | 713 | Ok(vec![(action.into(), ctx)]) |
| 714 | 714 | }, |
src/windows/mod.rs +25 −14
| @@ -475,7 +475,7 @@ fn room_prompt( | ||
| 475 | 475 | match act { |
| 476 | 476 | PromptAction::Submit => { |
| 477 | 477 | let room = IambId::Room(room_id.to_owned().into(), RoomView::Main); |
| 478 | let open = WindowAction::Switch(OpenTarget::Application(room)); | |
| 478 | let open = WindowAction::Switch(OpenTarget::Application(room), OpenFlags::NONE); | |
| 479 | 479 | let acts = vec![(open.into(), ctx.clone())]; |
| 480 | 480 | |
| 481 | 481 | Ok(acts) |
| @@ -622,7 +622,7 @@ impl IambWindow { | ||
| 622 | 622 | store: &mut ProgramStore, |
| 623 | 623 | ) -> IambResult<Vec<(Action<IambInfo>, ProgramContext)>> { |
| 624 | 624 | if let IambWindow::Room(w) = self { |
| 625 | w.join_command(act, ctx, store).await | |
| 625 | w.join_command(act, ctx, store) | |
| 626 | 626 | } else { |
| 627 | 627 | return Err(IambError::NoSelectedRoom.into()); |
| 628 | 628 | } |
| @@ -1213,22 +1213,33 @@ impl Window<IambInfo> for IambWindow { | ||
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | fn open(id: IambId, store: &mut ProgramStore) -> IambResult<Self> { | |
| 1216 | fn open(id: IambId, flags: OpenFlags, store: &mut ProgramStore) -> IambResult<Self> { | |
| 1217 | 1217 | match id { |
| 1218 | 1218 | IambId::Room(alias_id, thread) => { |
| 1219 | 1219 | let alias: &RoomOrAliasId = &alias_id; |
| 1220 | ||
| 1221 | let preview = |alias_id, store: &mut ProgramStore| -> RoomState { | |
| 1222 | let mut unjoined = RoomState::not_joined(alias_id, store); | |
| 1223 | if flags.contains(OpenFlags::FORCE) { | |
| 1224 | unjoined.join(store); | |
| 1225 | } | |
| 1226 | unjoined.into() | |
| 1227 | }; | |
| 1228 | ||
| 1220 | 1229 | let room_id = match <&RoomId>::try_from(alias) { |
| 1221 | 1230 | Ok(room_id) => room_id, |
| 1222 | 1231 | Err(alias) => { |
| 1223 | 1232 | if let Some(room_id) = store.application.aliases.get(alias) { |
| 1224 | 1233 | room_id |
| 1225 | 1234 | } else { |
| 1226 | return Ok(RoomState::not_joined(alias_id, store).into()); | |
| 1235 | return Ok(preview(alias_id, store).into()); | |
| 1227 | 1236 | } |
| 1228 | 1237 | }, |
| 1229 | 1238 | }; |
| 1230 | 1239 | |
| 1231 | if let Some(room) = store.application.worker.client.get_room(room_id) { | |
| 1240 | if let Some(room) = store.application.worker.client.get_room(room_id) && | |
| 1241 | room.state() != MatrixRoomState::Left | |
| 1242 | { | |
| 1232 | 1243 | store.application.need_load.need_members(room_id.to_owned()); |
| 1233 | 1244 | |
| 1234 | 1245 | let room = RoomState::new(room, thread, store); |
| @@ -1236,7 +1247,7 @@ impl Window<IambInfo> for IambWindow { | ||
| 1236 | 1247 | return Ok(room.into()); |
| 1237 | 1248 | } |
| 1238 | 1249 | |
| 1239 | return Ok(RoomState::not_joined(alias_id, store).into()); | |
| 1250 | return Ok(preview(alias_id, store).into()); | |
| 1240 | 1251 | }, |
| 1241 | 1252 | IambId::DirectList => { |
| 1242 | 1253 | let list = RoomListState::new(IambBufferId::DirectList, vec![]); |
| @@ -1305,7 +1316,7 @@ impl Window<IambInfo> for IambWindow { | ||
| 1305 | 1316 | } |
| 1306 | 1317 | } |
| 1307 | 1318 | |
| 1308 | fn find(name: String, store: &mut ProgramStore) -> IambResult<Self> { | |
| 1319 | fn find(name: String, flags: OpenFlags, store: &mut ProgramStore) -> IambResult<Self> { | |
| 1309 | 1320 | let room_alias = if let Ok(alias) = <&RoomAliasId>::try_from(name.as_str()) { |
| 1310 | 1321 | if let Some(room_id) = store.application.aliases.get(alias) { |
| 1311 | 1322 | room_id.to_owned().into() |
| @@ -1322,27 +1333,27 @@ impl Window<IambInfo> for IambWindow { | ||
| 1322 | 1333 | } |
| 1323 | 1334 | } else if let Ok(uri) = MatrixUri::parse(name.as_str()) { |
| 1324 | 1335 | let id = resolve_mxid(store, uri.id().to_owned(), uri.via().to_owned())?; |
| 1325 | return IambWindow::open(id, store); | |
| 1336 | return IambWindow::open(id, flags, store); | |
| 1326 | 1337 | } else if let Ok(uri) = MatrixToUri::parse(name.as_str()) { |
| 1327 | 1338 | let id = resolve_mxid(store, uri.id().to_owned(), uri.via().to_owned())?; |
| 1328 | return IambWindow::open(id, store); | |
| 1339 | return IambWindow::open(id, flags, store); | |
| 1329 | 1340 | } else { |
| 1330 | 1341 | return Err(UIError::Failure("Could not parse room identifier".to_string())); |
| 1331 | 1342 | }; |
| 1332 | 1343 | |
| 1333 | 1344 | let id = IambId::Room(room_alias, RoomView::Main); |
| 1334 | IambWindow::open(id, store) | |
| 1345 | IambWindow::open(id, flags, store) | |
| 1335 | 1346 | } |
| 1336 | 1347 | |
| 1337 | fn posn(index: usize, _: &mut ProgramStore) -> IambResult<Self> { | |
| 1348 | fn posn(index: usize, _: OpenFlags, _: &mut ProgramStore) -> IambResult<Self> { | |
| 1338 | 1349 | let msg = format!("Cannot find indexed buffer (index = {index})"); |
| 1339 | 1350 | let err = UIError::Unimplemented(msg); |
| 1340 | 1351 | |
| 1341 | 1352 | Err(err) |
| 1342 | 1353 | } |
| 1343 | 1354 | |
| 1344 | fn unnamed(store: &mut ProgramStore) -> IambResult<Self> { | |
| 1345 | Self::open(IambId::RoomList, store) | |
| 1355 | fn unnamed(flags: OpenFlags, store: &mut ProgramStore) -> IambResult<Self> { | |
| 1356 | Self::open(IambId::RoomList, flags, store) | |
| 1346 | 1357 | } |
| 1347 | 1358 | } |
| 1348 | 1359 | |
| @@ -1849,7 +1860,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for PinnedItem { | ||
| 1849 | 1860 | .map(ToOwned::to_owned); |
| 1850 | 1861 | |
| 1851 | 1862 | let room = IambId::Room(self.room_id.clone().into(), thread.into()); |
| 1852 | let open = WindowAction::Switch(OpenTarget::Application(room)); | |
| 1863 | let open = WindowAction::Switch(OpenTarget::Application(room), OpenFlags::NONE); | |
| 1853 | 1864 | let jump = IambAction::from(TimelineAction::GotoEvent(self.event_id.clone())); |
| 1854 | 1865 | |
| 1855 | 1866 | Ok(vec![(open.into(), ctx.clone()), (jump.into(), ctx.clone())]) |
src/windows/room/message.rs +9 −4
| @@ -99,9 +99,13 @@ impl MessageState { | ||
| 99 | 99 | let msg = "Selected message is not a reply"; |
| 100 | 100 | return Err(UIError::Failure(msg.into())); |
| 101 | 101 | }; |
| 102 | let act = Action::Window(WindowAction::Switch(OpenTarget::Application( | |
| 103 | IambId::Room(self.room_id().to_owned().into(), RoomView::Message(reply.into())), | |
| 104 | ))); | |
| 102 | let act = Action::Window(WindowAction::Switch( | |
| 103 | OpenTarget::Application(IambId::Room( | |
| 104 | self.room_id().to_owned().into(), | |
| 105 | RoomView::Message(reply.into()), | |
| 106 | )), | |
| 107 | OpenFlags::NONE, | |
| 108 | )); | |
| 105 | 109 | |
| 106 | 110 | Ok(vec![(act, ctx)]) |
| 107 | 111 | }, |
| @@ -581,7 +585,8 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for MessageInfoItem { | ||
| 581 | 585 | room_id.to_owned().into(), |
| 582 | 586 | RoomView::Thread(event_id.to_owned()), |
| 583 | 587 | ); |
| 584 | let open = WindowAction::Switch(OpenTarget::Application(id)); | |
| 588 | let open = | |
| 589 | WindowAction::Switch(OpenTarget::Application(id), OpenFlags::NONE); | |
| 585 | 590 | Ok(vec![(open.into(), ctx.clone())]) |
| 586 | 591 | }, |
| 587 | 592 | MessageInfoItem::Message(_, MessageId::Local(_)) => { |
src/windows/room/mod.rs +9 −7
| @@ -20,9 +20,11 @@ use crate::config::EncryptionIndicatorLocation; | ||
| 20 | 20 | use crate::prelude::*; |
| 21 | 21 | use crate::windows::room::chat::ChatState; |
| 22 | 22 | use crate::windows::room::message::{MessageState, MessageWidget}; |
| 23 | use crate::windows::room::not_joined::{NotJoined, NotJoinedState}; | |
| 23 | use crate::windows::room::not_joined::NotJoined; | |
| 24 | 24 | use crate::windows::room::space::{Space, SpaceState}; |
| 25 | 25 | |
| 26 | pub use crate::windows::room::not_joined::NotJoinedState; | |
| 27 | ||
| 26 | 28 | mod chat; |
| 27 | 29 | mod message; |
| 28 | 30 | mod not_joined; |
| @@ -638,7 +640,7 @@ pub async fn room_command( | ||
| 638 | 640 | let response = worker.client.send(request).await.map_err(IambError::from)?; |
| 639 | 641 | let id = IambId::Room(response.replacement_room.into(), RoomView::Main); |
| 640 | 642 | let target = OpenTarget::Application(id); |
| 641 | let act = WindowAction::Switch(target); | |
| 643 | let act = WindowAction::Switch(target, OpenFlags::NONE); | |
| 642 | 644 | |
| 643 | 645 | Ok(vec![(act.into(), ctx)]) |
| 644 | 646 | }, |
| @@ -705,8 +707,8 @@ impl RoomState { | ||
| 705 | 707 | } |
| 706 | 708 | } |
| 707 | 709 | |
| 708 | pub fn not_joined(alias: OwnedRoomOrAliasId, store: &mut ProgramStore) -> Self { | |
| 709 | Self::from(NotJoinedState::new(alias, store)) | |
| 710 | pub fn not_joined(alias: OwnedRoomOrAliasId, store: &mut ProgramStore) -> NotJoinedState { | |
| 711 | NotJoinedState::new(alias, store) | |
| 710 | 712 | } |
| 711 | 713 | |
| 712 | 714 | pub fn window_id(&self) -> IambId { |
| @@ -744,7 +746,7 @@ impl RoomState { | ||
| 744 | 746 | } else { |
| 745 | 747 | room.room_id().to_owned().into() |
| 746 | 748 | }; |
| 747 | *self = Self::not_joined(alias_id, store); | |
| 749 | *self = Self::not_joined(alias_id, store).into(); | |
| 748 | 750 | } |
| 749 | 751 | |
| 750 | 752 | match self { |
| @@ -855,14 +857,14 @@ impl RoomState { | ||
| 855 | 857 | } |
| 856 | 858 | } |
| 857 | 859 | |
| 858 | pub async fn join_command( | |
| 860 | pub fn join_command( | |
| 859 | 861 | &mut self, |
| 860 | 862 | act: JoinAction, |
| 861 | 863 | ctx: ProgramContext, |
| 862 | 864 | store: &mut ProgramStore, |
| 863 | 865 | ) -> IambResult<Vec<(Action<IambInfo>, ProgramContext)>> { |
| 864 | 866 | if let RoomState::NotJoined(nj) = self { |
| 865 | nj.join_command(act, ctx, store).await | |
| 867 | nj.join_command(act, ctx, store) | |
| 866 | 868 | } else { |
| 867 | 869 | Err(IambError::NoSelectedSpace.into()) |
| 868 | 870 | } |
src/windows/room/not_joined.rs +31 −17
| @@ -1,5 +1,5 @@ | ||
| 1 | use matrix_sdk::ruma::RoomOrAliasId; | |
| 2 | 1 | use matrix_sdk::ruma::room::{JoinRuleSummary, RestrictedSummary, RoomType as MatrixRoomType}; |
| 2 | use matrix_sdk::ruma::{RoomAliasId, RoomOrAliasId}; | |
| 3 | 3 | |
| 4 | 4 | use crate::base::{HomeserverAction, SyncInfo}; |
| 5 | 5 | use crate::prelude::*; |
| @@ -105,9 +105,20 @@ impl NotJoinedState { | ||
| 105 | 105 | { |
| 106 | 106 | room |
| 107 | 107 | } else { |
| 108 | if let Some(Err(e)) = self.joining.as_ref().and_then(|chan| chan.try_recv()) { | |
| 109 | self.err = Some(e.to_string()); | |
| 110 | self.joining = None; | |
| 108 | match self.joining.as_ref().and_then(|chan| chan.try_recv())? { | |
| 109 | Err(e) => { | |
| 110 | self.err = Some(e.to_string()); | |
| 111 | self.joining = None; | |
| 112 | }, | |
| 113 | Ok(room_id) => { | |
| 114 | // It is technically possible for a custom room alias to exist on a server | |
| 115 | // that is not then listed in the room's state events, so we make sure | |
| 116 | // to map the alias we used to join to the room ID at this point, so that | |
| 117 | // we can guarantee we see the room next time we're refreshed. | |
| 118 | if let Ok(alias) = <&RoomAliasId>::try_from(self.alias.deref()) { | |
| 119 | store.application.aliases.insert(alias.to_owned(), room_id); | |
| 120 | } | |
| 121 | }, | |
| 111 | 122 | } |
| 112 | 123 | return None; |
| 113 | 124 | }; |
| @@ -169,7 +180,21 @@ impl NotJoinedState { | ||
| 169 | 180 | ]) |
| 170 | 181 | } |
| 171 | 182 | |
| 172 | pub async fn join_command( | |
| 183 | pub fn join(&mut self, store: &mut ProgramStore) { | |
| 184 | let via = store | |
| 185 | .application | |
| 186 | .room_via | |
| 187 | .get(self.alias()) | |
| 188 | .unwrap_or(&store.application.settings.tunables.default_via) | |
| 189 | .iter() | |
| 190 | .cloned() | |
| 191 | .collect(); | |
| 192 | let chan = store.application.worker.join_room_chan(self.alias().to_owned(), via); | |
| 193 | self.joining = Some(chan); | |
| 194 | self.err = None; | |
| 195 | } | |
| 196 | ||
| 197 | pub fn join_command( | |
| 173 | 198 | &mut self, |
| 174 | 199 | act: JoinAction, |
| 175 | 200 | ctx: ProgramContext, |
| @@ -177,18 +202,7 @@ impl NotJoinedState { | ||
| 177 | 202 | ) -> IambResult<Vec<(Action<IambInfo>, ProgramContext)>> { |
| 178 | 203 | match act { |
| 179 | 204 | JoinAction::Join => { |
| 180 | let via = store | |
| 181 | .application | |
| 182 | .room_via | |
| 183 | .get(self.alias()) | |
| 184 | .unwrap_or(&store.application.settings.tunables.default_via) | |
| 185 | .iter() | |
| 186 | .cloned() | |
| 187 | .collect(); | |
| 188 | ||
| 189 | let chan = store.application.worker.join_room_chan(self.alias().to_owned(), via); | |
| 190 | self.joining = Some(chan); | |
| 191 | ||
| 205 | self.join(store); | |
| 192 | 206 | Ok(vec![]) |
| 193 | 207 | }, |
| 194 | 208 | JoinAction::Knock => { |
src/windows/room/scrollback.rs +1 −1
| @@ -1032,7 +1032,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 1032 | 1032 | }; |
| 1033 | 1033 | let room_id = self.room_id.clone(); |
| 1034 | 1034 | let id = IambId::Room(room_id.into(), RoomView::Thread(root.to_owned())); |
| 1035 | let open = WindowAction::Switch(OpenTarget::Application(id)); | |
| 1035 | let open = WindowAction::Switch(OpenTarget::Application(id), OpenFlags::NONE); | |
| 1036 | 1036 | Ok(vec![(open.into(), ctx.clone())]) |
| 1037 | 1037 | } |
| 1038 | 1038 | }, |