File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
labs/multiverse/src/widgets/room_view Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ struct Cli {
15
15
#[ derive( Debug , Subcommand ) ]
16
16
pub enum Command {
17
17
Invite { user_id : String } ,
18
+ Leave ,
18
19
}
19
20
20
21
pub enum MessageOrCommand {
Original file line number Diff line number Diff line change @@ -300,9 +300,28 @@ impl RoomView {
300
300
}
301
301
}
302
302
303
+ async fn leave_room ( & mut self ) {
304
+ let Some ( room) = self
305
+ . selected_room
306
+ . as_deref ( )
307
+ . and_then ( |room_id| self . ui_rooms . lock ( ) . get ( room_id) . cloned ( ) )
308
+ else {
309
+ self . status_handle
310
+ . set_message ( format ! ( "Coulnd't find the room object to leave the room" ) ) ;
311
+ return ;
312
+ } ;
313
+
314
+ let _ = room. leave ( ) . await . inspect_err ( |e| {
315
+ self . status_handle . set_message ( format ! ( "Couldn't leave the room {e:?}" ) )
316
+ } ) ;
317
+
318
+ self . input . clear ( ) ;
319
+ }
320
+
303
321
async fn handle_command ( & mut self , command : input:: Command ) {
304
322
match command {
305
323
input:: Command :: Invite { user_id } => self . invite_member ( & user_id) . await ,
324
+ input:: Command :: Leave => self . leave_room ( ) . await ,
306
325
}
307
326
}
308
327
You can’t perform that action at this time.
0 commit comments