Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/home/invite_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ live_design! {
icon_walk: {width: 16, height: 16, margin: {left: -2, right: -1} }

draw_bg: {
border_size: 1.0
border_size: 0.75
border_color: (COLOR_BG_DISABLED),
color: (COLOR_SECONDARY)
}
Expand All @@ -98,6 +98,7 @@ live_design! {
icon_walk: {width: 16, height: 16, margin: {left: -2, right: -1} }

draw_bg: {
border_size: 0.75
border_color: (COLOR_FG_ACCEPT_GREEN),
color: (COLOR_BG_ACCEPT_GREEN)
}
Expand Down
36 changes: 34 additions & 2 deletions src/home/space_lobby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use crate::shared::avatar::AvatarState;
use crate::utils::replace_linebreaks_separators;
use crate::{
avatar_cache::{self, AvatarCacheEntry},
home::rooms_list::RoomsListRef,
home::{
invite_modal::InviteModalAction,
rooms_list::RoomsListRef,
},
shared::avatar::{AvatarWidgetExt, AvatarWidgetRefExt},
space_service_sync::{SpaceRequest, SpaceRoomExt, SpaceRoomListAction},
utils::{self, RoomNameId},
Expand All @@ -33,6 +36,7 @@ live_design! {
use crate::shared::styles::*;
use crate::shared::helpers::*;
use crate::shared::avatar::*;
use crate::shared::icon_button::RobrixIconButton;

ICON_COLLAPSE = dep("crate://self/resources/icons/triangle_fill.svg")

Expand Down Expand Up @@ -433,6 +437,27 @@ live_design! {
}
text: ""
}

invite_button = <RobrixIconButton> {
width: Fit
align: {x: 0.5, y: 0.5}
padding: 12,
draw_icon: {
svg_file: (ICON_ADD_USER)
color: (COLOR_FG_ACCEPT_GREEN),
}
icon_walk: {width: 16, height: 16, margin: {left: -2, right: -1} }

draw_bg: {
border_size: 0.75
border_color: (COLOR_FG_ACCEPT_GREEN),
color: (COLOR_BG_ACCEPT_GREEN)
}
text: "Invite"
draw_text:{
color: (COLOR_FG_ACCEPT_GREEN),
}
}
}
}

Expand Down Expand Up @@ -779,8 +804,15 @@ impl Widget for SpaceLobbyScreen {
// TODO: Navigate to the room
}
}

// Handle the invite button being clicked in the header.
if self.view.button(ids!(header.parent_space_row.invite_button)).clicked(actions) {
if let Some(room_name_id) = self.space_name_id.as_ref() {
cx.action(InviteModalAction::Open(room_name_id.clone()));
}
}
}
}
}

fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
while let Some(widget_to_draw) = self.view.draw_walk(cx, scope, walk).step() {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/confirmation_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ live_design! {
icon_walk: {width: 0, height: 0, margin: 0}

draw_bg: {
border_size: 1.0
border_size: 0.75
border_color: (COLOR_BG_DISABLED),
color: (COLOR_SECONDARY)
}
Expand All @@ -95,7 +95,7 @@ live_design! {
icon_walk: {width: 0, height: 0, margin: 0}

draw_bg: {
border_size: 1.0
border_size: 0.75
border_color: (COLOR_ACTIVE_PRIMARY_DARKER),
color: (COLOR_ACTIVE_PRIMARY)
}
Expand Down
55 changes: 26 additions & 29 deletions src/sliding_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,27 +766,31 @@ async fn matrix_worker_task(
}

MatrixRequest::InviteUser { room_id, user_id } => {
let timeline = {
let all_joined_rooms = ALL_JOINED_ROOMS.lock().unwrap();
let Some(room_info) = all_joined_rooms.get(&room_id) else {
error!("BUG: room info not found for invite user request {room_id}, {user_id}");
continue;
};
room_info.timeline.clone()
};

let Some(client) = get_client() else { continue };
let _invite_task = Handle::current().spawn(async move {
log!("Sending request to invite user {user_id} to room {room_id}...");
match timeline.room().invite_user_by_id(&user_id).await {
Ok(_) => Cx::post_action(InviteResultAction::Sent {
room_id,
user_id,
}),
Err(error) => Cx::post_action(InviteResultAction::Failed {
// We use `client.get_room()` here because the room might also be a space,
// not just a joined room.
if let Some(room) = client.get_room(&room_id) {
log!("Sending request to invite user {user_id} to room {room_id}...");
match room.invite_user_by_id(&user_id).await {
Ok(_) => Cx::post_action(InviteResultAction::Sent {
room_id,
user_id,
}),
Err(error) => Cx::post_action(InviteResultAction::Failed {
room_id,
user_id,
error,
}),
}
}
else {
error!("Room/Space not found for invite user request {room_id}, {user_id}");
Cx::post_action(InviteResultAction::Failed {
room_id,
user_id,
error,
}),
error: matrix_sdk::Error::UnknownError("Room/Space not found in client's known list.".into()),
})
}
});
}
Expand Down Expand Up @@ -842,9 +846,7 @@ async fn matrix_worker_task(
error!("BUG: client could not get room with ID {room_id}");
LeaveRoomResultAction::Failed {
room_id,
error: matrix_sdk::Error::UnknownError(
String::from("Client couldn't locate room to leave it.").into()
),
error: matrix_sdk::Error::UnknownError("Client couldn't locate room to leave it.".into()),
}
};
Cx::post_action(result_action);
Expand Down Expand Up @@ -3597,14 +3599,9 @@ async fn spawn_sso_server(
break
}
}
Uri::new(&sso_url).open().map_err(|err| {
Error::UnknownError(
Box::new(io::Error::other(
format!("Unable to open SSO login url. Error: {:?}", err),
))
.into(),
)
})
Uri::new(&sso_url).open().map_err(|err|
Error::Io(io::Error::other(format!("Unable to open SSO login url. Error: {:?}", err)))
)
})
.identity_provider_id(&identity_provider_id)
.initial_device_display_name(&format!("robrix-sso-{brand}"))
Expand Down