mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 11:05:32 -04:00
feat(multiverse): Add a /leave command
This commit is contained in:
@@ -15,6 +15,7 @@ struct Cli {
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Command {
|
||||
Invite { user_id: String },
|
||||
Leave,
|
||||
}
|
||||
|
||||
pub enum MessageOrCommand {
|
||||
|
||||
@@ -300,9 +300,28 @@ impl RoomView {
|
||||
}
|
||||
}
|
||||
|
||||
async fn leave_room(&mut self) {
|
||||
let Some(room) = self
|
||||
.selected_room
|
||||
.as_deref()
|
||||
.and_then(|room_id| self.ui_rooms.lock().get(room_id).cloned())
|
||||
else {
|
||||
self.status_handle
|
||||
.set_message(format!("Coulnd't find the room object to leave the room"));
|
||||
return;
|
||||
};
|
||||
|
||||
let _ = room.leave().await.inspect_err(|e| {
|
||||
self.status_handle.set_message(format!("Couldn't leave the room {e:?}"))
|
||||
});
|
||||
|
||||
self.input.clear();
|
||||
}
|
||||
|
||||
async fn handle_command(&mut self, command: input::Command) {
|
||||
match command {
|
||||
input::Command::Invite { user_id } => self.invite_member(&user_id).await,
|
||||
input::Command::Leave => self.leave_room().await,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user