|
fn navigate_to_room( |
|
&mut self, |
|
cx: &mut Cx, |
|
room_to_close: Option<&OwnedRoomId>, |
|
destination_room: &BasicRoomDetails, |
|
) { |
|
// A closure that closes the given `room_to_close`, if it exists in an open tab. |
|
let close_room_closure_opt = room_to_close.map(|to_close| { |
|
let tab_id = LiveId::from_str(to_close.as_str()); |
|
let widget_uid = self.ui.widget_uid(); |
|
move |cx: &mut Cx| { |
|
cx.widget_action( |
|
widget_uid, |
|
&HeapLiveIdPath::default(), |
|
DockAction::TabCloseWasPressed(tab_id), |
|
); |
|
enqueue_rooms_list_update(RoomsListUpdate::HideRoom { room_id: to_close.clone() }); |
|
} |
|
}); |
|
|
|
// If the successor room is not loaded, show a join modal. |
|
let destination_room_id = destination_room.room_name_id.room_id(); |
|
if !cx.get_global::<RoomsListRef>().is_room_loaded(destination_room_id) { |
|
log!("Destination room {} not loaded, showing join modal...", destination_room_id); |
|
self.waiting_to_navigate_to_joined_room = Some(( |
|
destination_room.clone(), |
|
room_to_close.cloned(), |
|
)); |
|
cx.action(JoinLeaveRoomModalAction::Open { |
|
kind: JoinLeaveModalKind::JoinRoom(destination_room.clone()), |
|
show_tip: false, |
|
}); |
|
return; |
|
} |
|
|
|
log!( |
|
"Navigating to destination room {} ({}), closing room {room_to_close:?}", |
|
destination_room_id, |
|
destination_room.room_name_id |
|
); |
|
|
|
// Select and scroll to the destination room in the rooms list. |
|
let new_selected_room = SelectedRoom::JoinedRoom { |
|
room_name_id: destination_room.room_name_id.clone(), |
|
}; |
|
enqueue_rooms_list_update(RoomsListUpdate::ScrollToRoom(destination_room_id.clone())); |
|
cx.widget_action( |
|
self.ui.widget_uid(), |
|
&HeapLiveIdPath::default(), |
|
RoomsListAction::Selected(new_selected_room), |
|
); |
|
|
|
// Close a previously/currently-open room if specified. |
|
if let Some(closure) = close_room_closure_opt { |
|
closure(cx); |
|
} |
|
} |
|
} |
Although the room InviteScreen is fully functional and works properly, there are still some ways we could make it a bit nicer looking and sleeker.
set_displayed_invite()), change the join button icon to an "enter room" icon, and set the button as enabled and the button text to be "Join room".JoinRoomResultAction::Joinedhas been received, change the button icon to a green checkmark: " ✅ Joined!"robrix/src/app.rs
Lines 536 to 593 in d7117c3