diff --git a/src/session/model/room/mod.rs b/src/session/model/room/mod.rs index 29091ae9..b7078a7c 100644 --- a/src/session/model/room/mod.rs +++ b/src/session/model/room/mod.rs @@ -2089,47 +2089,6 @@ impl Room { } } - /// Accept the invitation to this room. - pub async fn accept_invite(&self) -> MatrixResult<()> { - let matrix_room = self.matrix_room(); - - if matrix_room.state() != RoomState::Invited { - error!("Can’t accept invite, because this room isn’t an invited room"); - return Ok(()); - } - - let matrix_room = matrix_room.clone(); - let handle = spawn_tokio!(async move { matrix_room.join().await }); - match handle.await.expect("task was not aborted") { - Ok(_) => Ok(()), - Err(error) => { - error!("Accepting invitation failed: {error}"); - Err(error) - } - } - } - - /// Decline the invitation to this room. - pub async fn decline_invite(&self) -> MatrixResult<()> { - let matrix_room = self.matrix_room(); - - if matrix_room.state() != RoomState::Invited { - error!("Cannot decline invite, because this room is not an invited room"); - return Ok(()); - } - - let matrix_room = matrix_room.clone(); - let handle = spawn_tokio!(async move { matrix_room.leave().await }); - match handle.await.expect("task was not aborted") { - Ok(_) => Ok(()), - Err(error) => { - error!("Declining invitation failed: {error}"); - - Err(error) - } - } - } - /// Forget a room that is left. pub async fn forget(&self) -> MatrixResult<()> { if self.category() != RoomCategory::Left { diff --git a/src/session/view/content/invite.rs b/src/session/view/content/invite.rs index 2989d0c1..5bfafbfe 100644 --- a/src/session/view/content/invite.rs +++ b/src/session/view/content/invite.rs @@ -239,8 +239,7 @@ impl Invite { imp.accept_button.set_is_loading(true); imp.accept_requests.borrow_mut().insert(room.clone()); - let result = room.accept_invite().await; - if result.is_err() { + if room.set_category(RoomCategory::Normal).await.is_err() { toast!( self, gettext( @@ -274,7 +273,7 @@ impl Invite { let ignored_inviter = response.ignore_inviter.then(|| room.inviter()).flatten(); - let closed = match room.decline_invite().await { + let closed = match room.set_category(RoomCategory::Left).await { Ok(_) => { // A room where we were invited is usually empty so just close it. let _ = self.activate_action("session.close-room", None);