diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index c15c3736..5b2bd812 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -1434,6 +1434,8 @@ impl RoomScreen { /// /// Redraws this RoomScreen view if any updates were applied. fn process_timeline_updates(&mut self, cx: &mut Cx, portal_list: &PortalListRef) { + // Check if the user has permission to send message in this room. + self.check_user_permission(); let top_space = self.view(id!(top_space)); let bottom_input = self.view(id!(bottom_input)); let no_send_permisson_notice = self.view(id!(no_send_permisson_notice)); @@ -1580,7 +1582,8 @@ impl RoomScreen { typing_users = users; } TimelineUpdate::SendPermission(can_send) => { - if !can_send { + log!("YESYES"); + if can_send == -1 { bottom_input.set_visible(false); no_send_permisson_notice.set_visible(true) } @@ -1762,8 +1765,6 @@ impl RoomScreen { submit_async_request(MatrixRequest::FetchRoomMembers { room_id }); } - // Check if the user has permission to send message in this room. - self.check_user_permission(); // Now, restore the visual state of this timeline from its previously-saved state. self.restore_state(cx, &mut tl_state); @@ -2031,7 +2032,7 @@ pub enum TimelineUpdate { users: Vec, }, /// if the user has permission to send messages in this room - SendPermission(bool), + SendPermission(i64), } /// The global set of all timeline states, one entry per room. diff --git a/src/sliding_sync.rs b/src/sliding_sync.rs index b58f67df..be58dc21 100644 --- a/src/sliding_sync.rs +++ b/src/sliding_sync.rs @@ -714,13 +714,14 @@ async fn async_worker( let Some(client) = CLIENT.get() else { continue }; let Some(user_id) = client.user_id() else { continue }; - let _send_frr_task = Handle::current().spawn(async move { + let _check_user_send_permission_task = Handle::current().spawn(async move { let room = timeline.room(); - let can_send = room.can_user_send_message(user_id, matrix_sdk::ruma::events::MessageLikeEventType::Message).await.unwrap_or(false); + let can_send = room.get_user_power_level(user_id).await.unwrap_or(0); if let Err(_) = sender.send(TimelineUpdate::SendPermission(can_send)) { error!("Failed to send the result of user send permission") } + SignalToUI::set_ui_signal(); }); } }