Commit a5c25f2487
Unregistered key
Layout: unified · split
Cargo.lock +62 −17
| @@ -625,6 +625,22 @@ dependencies = [ | ||
| 625 | 625 | "winapi", |
| 626 | 626 | ] |
| 627 | 627 | |
| 628 | [[package]] | |
| 629 | name = "crossterm" | |
| 630 | version = "0.26.1" | |
| 631 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 632 | checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" | |
| 633 | dependencies = [ | |
| 634 | "bitflags 1.3.2", | |
| 635 | "crossterm_winapi", | |
| 636 | "libc", | |
| 637 | "mio", | |
| 638 | "parking_lot 0.12.1", | |
| 639 | "signal-hook", | |
| 640 | "signal-hook-mio", | |
| 641 | "winapi", | |
| 642 | ] | |
| 643 | ||
| 628 | 644 | [[package]] |
| 629 | 645 | name = "crossterm_winapi" |
| 630 | 646 | version = "0.9.0" |
| @@ -2006,24 +2022,26 @@ dependencies = [ | ||
| 2006 | 2022 | |
| 2007 | 2023 | [[package]] |
| 2008 | 2024 | name = "modalkit" |
| 2009 | version = "0.0.14" | |
| 2025 | version = "0.0.15" | |
| 2010 | 2026 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2011 | checksum = "5c48c7d7e6d764a09435b43a7e4d342ba2d2e026626ca773b16a5ba34b90b933" | |
| 2027 | checksum = "b44af1b5a7737da948719b907c870b4c852f1d98300d873bd12568f4028d908a" | |
| 2012 | 2028 | dependencies = [ |
| 2013 | 2029 | "anymap2", |
| 2014 | 2030 | "arboard", |
| 2015 | 2031 | "bitflags 1.3.2", |
| 2016 | "crossterm", | |
| 2032 | "crossterm 0.25.0", | |
| 2017 | 2033 | "derive_more", |
| 2018 | 2034 | "intervaltree", |
| 2019 | 2035 | "libc", |
| 2020 | 2036 | "nom", |
| 2021 | 2037 | "radix_trie", |
| 2038 | "ratatui", | |
| 2022 | 2039 | "regex", |
| 2023 | 2040 | "ropey", |
| 2041 | "textwrap", | |
| 2024 | 2042 | "thiserror", |
| 2025 | "tui", | |
| 2026 | 2043 | "unicode-segmentation", |
| 2044 | "unicode-width", | |
| 2027 | 2045 | ] |
| 2028 | 2046 | |
| 2029 | 2047 | [[package]] |
| @@ -2699,6 +2717,19 @@ dependencies = [ | ||
| 2699 | 2717 | "rand_core 0.3.1", |
| 2700 | 2718 | ] |
| 2701 | 2719 | |
| 2720 | [[package]] | |
| 2721 | name = "ratatui" | |
| 2722 | version = "0.20.1" | |
| 2723 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 2724 | checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829" | |
| 2725 | dependencies = [ | |
| 2726 | "bitflags 1.3.2", | |
| 2727 | "cassowary", | |
| 2728 | "crossterm 0.26.1", | |
| 2729 | "unicode-segmentation", | |
| 2730 | "unicode-width", | |
| 2731 | ] | |
| 2732 | ||
| 2702 | 2733 | [[package]] |
| 2703 | 2734 | name = "rdrand" |
| 2704 | 2735 | version = "0.4.0" |
| @@ -3209,6 +3240,12 @@ version = "1.10.0" | ||
| 3209 | 3240 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3210 | 3241 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" |
| 3211 | 3242 | |
| 3243 | [[package]] | |
| 3244 | name = "smawk" | |
| 3245 | version = "0.3.1" | |
| 3246 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3247 | checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" | |
| 3248 | ||
| 3212 | 3249 | [[package]] |
| 3213 | 3250 | name = "socket2" |
| 3214 | 3251 | version = "0.4.9" |
| @@ -3383,6 +3420,17 @@ dependencies = [ | ||
| 3383 | 3420 | "windows-sys 0.48.0", |
| 3384 | 3421 | ] |
| 3385 | 3422 | |
| 3423 | [[package]] | |
| 3424 | name = "textwrap" | |
| 3425 | version = "0.16.0" | |
| 3426 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3427 | checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" | |
| 3428 | dependencies = [ | |
| 3429 | "smawk", | |
| 3430 | "unicode-linebreak", | |
| 3431 | "unicode-width", | |
| 3432 | ] | |
| 3433 | ||
| 3386 | 3434 | [[package]] |
| 3387 | 3435 | name = "thiserror" |
| 3388 | 3436 | version = "1.0.40" |
| @@ -3638,19 +3686,6 @@ version = "0.2.4" | ||
| 3638 | 3686 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3639 | 3687 | checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" |
| 3640 | 3688 | |
| 3641 | [[package]] | |
| 3642 | name = "tui" | |
| 3643 | version = "0.19.0" | |
| 3644 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3645 | checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" | |
| 3646 | dependencies = [ | |
| 3647 | "bitflags 1.3.2", | |
| 3648 | "cassowary", | |
| 3649 | "crossterm", | |
| 3650 | "unicode-segmentation", | |
| 3651 | "unicode-width", | |
| 3652 | ] | |
| 3653 | ||
| 3654 | 3689 | [[package]] |
| 3655 | 3690 | name = "typed-arena" |
| 3656 | 3691 | version = "2.0.2" |
| @@ -3684,6 +3719,16 @@ version = "1.0.8" | ||
| 3684 | 3719 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3685 | 3720 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" |
| 3686 | 3721 | |
| 3722 | [[package]] | |
| 3723 | name = "unicode-linebreak" | |
| 3724 | version = "0.1.4" | |
| 3725 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3726 | checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" | |
| 3727 | dependencies = [ | |
| 3728 | "hashbrown", | |
| 3729 | "regex", | |
| 3730 | ] | |
| 3731 | ||
| 3687 | 3732 | [[package]] |
| 3688 | 3733 | name = "unicode-normalization" |
| 3689 | 3734 | version = "0.1.22" |
Cargo.toml +1 −1
| @@ -40,7 +40,7 @@ unicode-width = "0.1.10" | ||
| 40 | 40 | url = {version = "^2.2.2", features = ["serde"]} |
| 41 | 41 | |
| 42 | 42 | [dependencies.modalkit] |
| 43 | version = "0.0.14" | |
| 43 | version = "0.0.15" | |
| 44 | 44 | |
| 45 | 45 | [dependencies.matrix-sdk] |
| 46 | 46 | version = "0.6" |
src/base.rs +4 −1
| @@ -118,7 +118,9 @@ pub enum MessageAction { | ||
| 118 | 118 | React(String), |
| 119 | 119 | |
| 120 | 120 | /// Redact a message, with an optional reason. |
| 121 | Redact(Option<String>), | |
| 121 | /// | |
| 122 | /// The [bool] argument indicates whether to skip confirmation. | |
| 123 | Redact(Option<String>, bool), | |
| 122 | 124 | |
| 123 | 125 | /// Reply to a message. |
| 124 | 126 | Reply, |
| @@ -178,6 +180,7 @@ pub enum RoomAction { | ||
| 178 | 180 | InviteAccept, |
| 179 | 181 | InviteReject, |
| 180 | 182 | InviteSend(OwnedUserId), |
| 183 | Leave(bool), | |
| 181 | 184 | Members(Box<CommandContext<ProgramContext>>), |
| 182 | 185 | Set(RoomField, String), |
| 183 | 186 | Unset(RoomField), |
src/commands.rs +25 −4
| @@ -161,6 +161,17 @@ fn iamb_members(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 161 | 161 | return Ok(step); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | |
| 165 | if !desc.arg.text.is_empty() { | |
| 166 | return Result::Err(CommandError::InvalidArgument); | |
| 167 | } | |
| 168 | ||
| 169 | let leave = IambAction::Room(RoomAction::Leave(desc.bang)); | |
| 170 | let step = CommandStep::Continue(leave.into(), ctx.context.take()); | |
| 171 | ||
| 172 | return Ok(step); | |
| 173 | } | |
| 174 | ||
| 164 | 175 | fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { |
| 165 | 176 | if !desc.arg.text.is_empty() { |
| 166 | 177 | return Result::Err(CommandError::InvalidArgument); |
| @@ -237,7 +248,8 @@ fn iamb_redact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 237 | 248 | return Result::Err(CommandError::InvalidArgument); |
| 238 | 249 | } |
| 239 | 250 | |
| 240 | let ract = IambAction::from(MessageAction::Redact(args.into_iter().next())); | |
| 251 | let reason = args.into_iter().next(); | |
| 252 | let ract = IambAction::from(MessageAction::Redact(reason, desc.bang)); | |
| 241 | 253 | let step = CommandStep::Continue(ract.into(), ctx.context.take()); |
| 242 | 254 | |
| 243 | 255 | return Ok(step); |
| @@ -469,6 +481,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) { | ||
| 469 | 481 | f: iamb_invite, |
| 470 | 482 | }); |
| 471 | 483 | cmds.add_command(ProgramCommand { name: "join".into(), aliases: vec![], f: iamb_join }); |
| 484 | cmds.add_command(ProgramCommand { | |
| 485 | name: "leave".into(), | |
| 486 | aliases: vec![], | |
| 487 | f: iamb_leave, | |
| 488 | }); | |
| 472 | 489 | cmds.add_command(ProgramCommand { |
| 473 | 490 | name: "members".into(), |
| 474 | 491 | aliases: vec![], |
| @@ -870,15 +887,19 @@ mod tests { | ||
| 870 | 887 | let ctx = ProgramContext::default(); |
| 871 | 888 | |
| 872 | 889 | let res = cmds.input_cmd("redact", ctx.clone()).unwrap(); |
| 873 | let act = IambAction::Message(MessageAction::Redact(None)); | |
| 890 | let act = IambAction::Message(MessageAction::Redact(None, false)); | |
| 891 | assert_eq!(res, vec![(act.into(), ctx.clone())]); | |
| 892 | ||
| 893 | let res = cmds.input_cmd("redact!", ctx.clone()).unwrap(); | |
| 894 | let act = IambAction::Message(MessageAction::Redact(None, true)); | |
| 874 | 895 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| 875 | 896 | |
| 876 | 897 | let res = cmds.input_cmd("redact Removed", ctx.clone()).unwrap(); |
| 877 | let act = IambAction::Message(MessageAction::Redact(Some("Removed".into()))); | |
| 898 | let act = IambAction::Message(MessageAction::Redact(Some("Removed".into()), false)); | |
| 878 | 899 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| 879 | 900 | |
| 880 | 901 | let res = cmds.input_cmd("redact \"Removed\"", ctx.clone()).unwrap(); |
| 881 | let act = IambAction::Message(MessageAction::Redact(Some("Removed".into()))); | |
| 902 | let act = IambAction::Message(MessageAction::Redact(Some("Removed".into()), false)); | |
| 882 | 903 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| 883 | 904 | |
| 884 | 905 | let res = cmds.input_cmd("redact Removed Removed", ctx.clone()); |
src/main.rs +44 −7
| @@ -76,12 +76,14 @@ use modalkit::{ | ||
| 76 | 76 | EditInfo, |
| 77 | 77 | Editable, |
| 78 | 78 | EditorAction, |
| 79 | InfoMessage, | |
| 79 | 80 | InsertTextAction, |
| 80 | 81 | Jumpable, |
| 81 | 82 | Promptable, |
| 82 | 83 | Scrollable, |
| 83 | 84 | TabContainer, |
| 84 | 85 | TabCount, |
| 86 | UIError, | |
| 85 | 87 | WindowAction, |
| 86 | 88 | WindowContainer, |
| 87 | 89 | }, |
| @@ -90,7 +92,7 @@ use modalkit::{ | ||
| 90 | 92 | key::KeyManager, |
| 91 | 93 | store::Store, |
| 92 | 94 | }, |
| 93 | input::{bindings::BindingMachine, key::TerminalKey}, | |
| 95 | input::{bindings::BindingMachine, dialog::Pager, key::TerminalKey}, | |
| 94 | 96 | widgets::{ |
| 95 | 97 | cmdbar::CommandBarState, |
| 96 | 98 | screen::{Screen, ScreenState}, |
| @@ -156,8 +158,7 @@ impl Application { | ||
| 156 | 158 | } |
| 157 | 159 | |
| 158 | 160 | fn redraw(&mut self, full: bool, store: &mut ProgramStore) -> Result<(), std::io::Error> { |
| 159 | let modestr = self.bindings.showmode(); | |
| 160 | let cursor = self.bindings.get_cursor_indicator(); | |
| 161 | let bindings = &mut self.bindings; | |
| 161 | 162 | let sstate = &mut self.screen; |
| 162 | 163 | let term = &mut self.terminal; |
| 163 | 164 | |
| @@ -168,9 +169,20 @@ impl Application { | ||
| 168 | 169 | term.draw(|f| { |
| 169 | 170 | let area = f.size(); |
| 170 | 171 | |
| 171 | let screen = Screen::new(store).showmode(modestr).borders(true); | |
| 172 | let modestr = bindings.show_mode(); | |
| 173 | let cursor = bindings.get_cursor_indicator(); | |
| 174 | let dialogstr = bindings.show_dialog(area.height as usize, area.width as usize); | |
| 175 | ||
| 176 | // Don't show terminal cursor when we show a dialog. | |
| 177 | let hide_cursor = !dialogstr.is_empty(); | |
| 178 | ||
| 179 | let screen = Screen::new(store).show_dialog(dialogstr).show_mode(modestr).borders(true); | |
| 172 | 180 | f.render_stateful_widget(screen, area, sstate); |
| 173 | 181 | |
| 182 | if hide_cursor { | |
| 183 | return; | |
| 184 | } | |
| 185 | ||
| 174 | 186 | if let Some((cx, cy)) = sstate.get_term_cursor() { |
| 175 | 187 | if let Some(c) = cursor { |
| 176 | 188 | let style = Style::default().fg(Color::Green); |
| @@ -215,7 +227,8 @@ impl Application { | ||
| 215 | 227 | match self.screen.editor_command(&act, &ctx, store.deref_mut()) { |
| 216 | 228 | Ok(None) => {}, |
| 217 | 229 | Ok(Some(info)) => { |
| 218 | self.screen.push_info(info); | |
| 230 | drop(store); | |
| 231 | self.handle_info(info); | |
| 219 | 232 | }, |
| 220 | 233 | Err(e) => { |
| 221 | 234 | self.screen.push_error(e); |
| @@ -279,7 +292,7 @@ impl Application { | ||
| 279 | 292 | Action::CommandBar(act) => self.screen.command_bar(&act, &ctx)?, |
| 280 | 293 | Action::Macro(act) => self.bindings.macro_command(&act, &ctx, store)?, |
| 281 | 294 | Action::Scroll(style) => self.screen.scroll(&style, &ctx, store)?, |
| 282 | Action::Suspend => self.terminal.program_suspend()?, | |
| 295 | Action::ShowInfoMessage(info) => Some(info), | |
| 283 | 296 | Action::Tab(cmd) => self.screen.tab_command(&cmd, &ctx, store)?, |
| 284 | 297 | Action::Window(cmd) => self.screen.window_command(&cmd, &ctx, store)?, |
| 285 | 298 | |
| @@ -289,6 +302,11 @@ impl Application { | ||
| 289 | 302 | |
| 290 | 303 | None |
| 291 | 304 | }, |
| 305 | Action::Suspend => { | |
| 306 | self.terminal.program_suspend()?; | |
| 307 | ||
| 308 | None | |
| 309 | }, | |
| 292 | 310 | |
| 293 | 311 | // UI actions. |
| 294 | 312 | Action::RedrawScreen => { |
| @@ -402,6 +420,18 @@ impl Application { | ||
| 402 | 420 | } |
| 403 | 421 | } |
| 404 | 422 | |
| 423 | fn handle_info(&mut self, info: InfoMessage) { | |
| 424 | match info { | |
| 425 | InfoMessage::Message(info) => { | |
| 426 | self.screen.push_info(info); | |
| 427 | }, | |
| 428 | InfoMessage::Pager(text) => { | |
| 429 | let pager = Box::new(Pager::new(text, vec![])); | |
| 430 | self.bindings.run_dialog(pager); | |
| 431 | }, | |
| 432 | } | |
| 433 | } | |
| 434 | ||
| 405 | 435 | pub async fn run(&mut self) -> Result<(), std::io::Error> { |
| 406 | 436 | self.terminal.clear()?; |
| 407 | 437 | |
| @@ -422,11 +452,18 @@ impl Application { | ||
| 422 | 452 | continue; |
| 423 | 453 | }, |
| 424 | 454 | Ok(Some(info)) => { |
| 425 | self.screen.push_info(info); | |
| 455 | self.handle_info(info); | |
| 426 | 456 | |
| 427 | 457 | // Continue processing; we'll redraw later. |
| 428 | 458 | continue; |
| 429 | 459 | }, |
| 460 | Err( | |
| 461 | UIError::NeedConfirm(dialog) | | |
| 462 | UIError::EditingFailure(EditError::NeedConfirm(dialog)), | |
| 463 | ) => { | |
| 464 | self.bindings.run_dialog(dialog); | |
| 465 | continue; | |
| 466 | }, | |
| 430 | 467 | Err(e) => { |
| 431 | 468 | self.screen.push_error(e); |
| 432 | 469 | |
src/windows/mod.rs +3 −3
| @@ -199,7 +199,7 @@ fn room_prompt( | ||
| 199 | 199 | |
| 200 | 200 | Err(err) |
| 201 | 201 | }, |
| 202 | PromptAction::Recall(_, _) => { | |
| 202 | PromptAction::Recall(..) => { | |
| 203 | 203 | let msg = "Cannot recall history inside a list"; |
| 204 | 204 | let err = EditError::Failure(msg.into()); |
| 205 | 205 | |
| @@ -1043,7 +1043,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for VerifyItem { | ||
| 1043 | 1043 | |
| 1044 | 1044 | Err(err) |
| 1045 | 1045 | }, |
| 1046 | PromptAction::Recall(_, _) => { | |
| 1046 | PromptAction::Recall(..) => { | |
| 1047 | 1047 | let msg = "Cannot recall history inside a list"; |
| 1048 | 1048 | let err = EditError::Failure(msg.into()); |
| 1049 | 1049 | |
| @@ -1120,7 +1120,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for MemberItem { | ||
| 1120 | 1120 | |
| 1121 | 1121 | Err(err) |
| 1122 | 1122 | }, |
| 1123 | PromptAction::Recall(_, _) => { | |
| 1123 | PromptAction::Recall(..) => { | |
| 1124 | 1124 | let msg = "Cannot recall history inside a list"; |
| 1125 | 1125 | let err = EditError::Failure(msg.into()); |
| 1126 | 1126 | |
src/windows/room/chat.rs +17 −3
| @@ -27,6 +27,7 @@ use matrix_sdk::{ | ||
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | 29 | use modalkit::{ |
| 30 | input::dialog::PromptYesNo, | |
| 30 | 31 | tui::{ |
| 31 | 32 | buffer::Buffer, |
| 32 | 33 | layout::Rect, |
| @@ -40,6 +41,7 @@ use modalkit::{ | ||
| 40 | 41 | |
| 41 | 42 | use modalkit::editing::{ |
| 42 | 43 | action::{ |
| 44 | Action, | |
| 43 | 45 | EditError, |
| 44 | 46 | EditInfo, |
| 45 | 47 | EditResult, |
| @@ -310,7 +312,16 @@ impl ChatState { | ||
| 310 | 312 | |
| 311 | 313 | Ok(None) |
| 312 | 314 | }, |
| 313 | MessageAction::Redact(reason) => { | |
| 315 | MessageAction::Redact(reason, skip_confirm) => { | |
| 316 | if !skip_confirm { | |
| 317 | let msg = "Are you sure you want to redact this message?"; | |
| 318 | let act = IambAction::Message(MessageAction::Redact(reason, true)); | |
| 319 | let prompt = PromptYesNo::new(msg, vec![Action::from(act)]); | |
| 320 | let prompt = Box::new(prompt); | |
| 321 | ||
| 322 | return Err(UIError::NeedConfirm(prompt)); | |
| 323 | } | |
| 324 | ||
| 314 | 325 | let room = self.get_joined(&store.application.worker)?; |
| 315 | 326 | let event_id = match &msg.event { |
| 316 | 327 | MessageEvent::EncryptedOriginal(ev) => ev.event_id.clone(), |
| @@ -672,13 +683,14 @@ impl PromptActions<ProgramContext, ProgramStore, IambInfo> for ChatState { | ||
| 672 | 683 | &mut self, |
| 673 | 684 | dir: &MoveDir1D, |
| 674 | 685 | count: &Count, |
| 686 | prefixed: bool, | |
| 675 | 687 | ctx: &ProgramContext, |
| 676 | 688 | _: &mut ProgramStore, |
| 677 | 689 | ) -> EditResult<Vec<(ProgramAction, ProgramContext)>, IambInfo> { |
| 678 | 690 | let count = ctx.resolve(count); |
| 679 | 691 | let rope = self.tbox.get(); |
| 680 | 692 | |
| 681 | let text = self.sent.recall(&rope, &mut self.sent_scrollback, *dir, count); | |
| 693 | let text = self.sent.recall(&rope, &mut self.sent_scrollback, *dir, prefixed, count); | |
| 682 | 694 | |
| 683 | 695 | if let Some(text) = text { |
| 684 | 696 | self.tbox.set_text(text); |
| @@ -702,7 +714,9 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ChatState { | ||
| 702 | 714 | match act { |
| 703 | 715 | PromptAction::Submit => self.submit(ctx, store), |
| 704 | 716 | PromptAction::Abort(empty) => self.abort(*empty, ctx, store), |
| 705 | PromptAction::Recall(dir, count) => self.recall(dir, count, ctx, store), | |
| 717 | PromptAction::Recall(dir, count, prefixed) => { | |
| 718 | self.recall(dir, count, *prefixed, ctx, store) | |
| 719 | }, | |
| 706 | 720 | _ => Err(EditError::Unimplemented("unknown prompt action".to_string())), |
| 707 | 721 | } |
| 708 | 722 | } |
src/windows/room/mod.rs +20
| @@ -43,11 +43,13 @@ use modalkit::{ | ||
| 43 | 43 | WriteFlags, |
| 44 | 44 | }, |
| 45 | 45 | editing::completion::CompletionList, |
| 46 | input::dialog::PromptYesNo, | |
| 46 | 47 | input::InputContext, |
| 47 | 48 | widgets::{TermOffset, TerminalCursor, WindowOps}, |
| 48 | 49 | }; |
| 49 | 50 | |
| 50 | 51 | use crate::base::{ |
| 52 | IambAction, | |
| 51 | 53 | IambError, |
| 52 | 54 | IambId, |
| 53 | 55 | IambInfo, |
| @@ -218,6 +220,24 @@ impl RoomState { | ||
| 218 | 220 | Err(IambError::NotJoined.into()) |
| 219 | 221 | } |
| 220 | 222 | }, |
| 223 | RoomAction::Leave(skip_confirm) => { | |
| 224 | if let Some(room) = store.application.worker.client.get_joined_room(self.id()) { | |
| 225 | if skip_confirm { | |
| 226 | room.leave().await.map_err(IambError::from)?; | |
| 227 | ||
| 228 | Ok(vec![]) | |
| 229 | } else { | |
| 230 | let msg = "Do you really want to leave this room?"; | |
| 231 | let leave = IambAction::Room(RoomAction::Leave(true)); | |
| 232 | let prompt = PromptYesNo::new(msg, vec![Action::from(leave)]); | |
| 233 | let prompt = Box::new(prompt); | |
| 234 | ||
| 235 | Err(UIError::NeedConfirm(prompt)) | |
| 236 | } | |
| 237 | } else { | |
| 238 | Err(IambError::NotJoined.into()) | |
| 239 | } | |
| 240 | }, | |
| 221 | 241 | RoomAction::Members(mut cmd) => { |
| 222 | 242 | let width = Count::Exact(30); |
| 223 | 243 | let act = |
src/worker.rs +1 −1
| @@ -1215,7 +1215,7 @@ impl ClientWorker { | ||
| 1215 | 1215 | let _req = request.await.map_err(IambError::from)?; |
| 1216 | 1216 | let info = format!("Sent verification request to {user_id}"); |
| 1217 | 1217 | |
| 1218 | Ok(InfoMessage::from(info).into()) | |
| 1218 | Ok(Some(InfoMessage::from(info))) | |
| 1219 | 1219 | }, |
| 1220 | 1220 | None => { |
| 1221 | 1221 | let msg = format!("Could not find identity information for {user_id}"); |