join-room-dialog: Fix action when dialog closes

This commit is contained in:
Kévin Commaille 2023-11-21 10:50:48 +01:00
parent 9d0409124c
commit 6daa803a5e
No known key found for this signature in database
GPG key ID: 29A48C1F03620416

View file

@ -156,19 +156,18 @@ impl JoinRoomDialog {
let Some(session) = self.session() else {
return;
};
let Some(window) = self.transient_for().and_downcast::<Window>() else {
return;
};
let room_list = session.room_list();
// Join or view the room with the given identifier.
if let Some(room) = room_list.joined_room((&*room_id).into()) {
let Some(window) = self.root().and_downcast::<Window>() else {
return;
};
window.session_view().select_room(Some(room));
} else {
spawn!(clone!(@weak self as obj, @weak room_list => async move {
spawn!(clone!(@weak window, @weak room_list => async move {
if let Err(error) = room_list.join_by_id_or_alias(room_id, via).await {
toast!(obj, error);
toast!(window, error);
}
}));
}