diff --git a/src/home/rooms_list.rs b/src/home/rooms_list.rs index 996c6318..ea3ec513 100644 --- a/src/home/rooms_list.rs +++ b/src/home/rooms_list.rs @@ -180,11 +180,14 @@ pub struct RoomsList { #[rust] max_known_rooms: Option, #[live] room_type: String } - +pub struct TotalLoadedRoomsCount(u32); impl RoomsList { - fn update_status_rooms_count(&mut self) { + fn update_status_rooms_count(&mut self, cx: &mut Cx) { + let total_loaded_rooms_count = if cx.has_global::() { + cx.get_global::().0 + } else { 0 }; self.status = if let Some(max_rooms) = self.max_known_rooms { - format!("Loaded {} of {} total rooms.", self.all_rooms.len(), max_rooms) + format!("Loaded {} of {} total rooms.", total_loaded_rooms_count, max_rooms) } else { format!("Loaded {} rooms.", self.all_rooms.len()) }; @@ -206,6 +209,11 @@ impl Widget for RoomsList { num_updates += 1; match update { RoomsListUpdate::AddRoom(room) => { + if cx.has_global::() { + cx.get_global::().0 += 1; + } else { + cx.set_global(TotalLoadedRoomsCount(1)); + } self.all_rooms.push(room); } RoomsListUpdate::UpdateRoomAvatar { room_id, avatar } => { @@ -244,7 +252,7 @@ impl Widget for RoomsList { } RoomsListUpdate::LoadedRooms { max_rooms } => { self.max_known_rooms = max_rooms; - self.update_status_rooms_count(); + self.update_status_rooms_count(cx); } RoomsListUpdate::Status { status } => { self.status = status; @@ -327,7 +335,7 @@ impl Widget for RoomsList { item } // Draw the status label as the bottom entry. - else if item_id == status_label_id { + else if item_id == status_label_id && self.room_type == "room" { let item = list.item(cx, item_id, live_id!(status_label)).unwrap(); item.as_view().apply_over(cx, live!{ height: Fit, diff --git a/src/home/rooms_sidebar.rs b/src/home/rooms_sidebar.rs index be1182da..59155c65 100644 --- a/src/home/rooms_sidebar.rs +++ b/src/home/rooms_sidebar.rs @@ -125,11 +125,17 @@ live_design! { } } } - - { + } + { + people_list = { + width: Fill, height: 75 room_type: "people" } - + } + { + flow: Down, spacing: 20 + padding: {top: 20}, + width: Fill, height: Fit { title = { text: "Channels" @@ -154,6 +160,7 @@ live_design! { } } { + height: Fit, rooms_list = { room_type: "room" } diff --git a/src/sliding_sync.rs b/src/sliding_sync.rs index 558692d8..9e9913f6 100644 --- a/src/sliding_sync.rs +++ b/src/sliding_sync.rs @@ -1203,9 +1203,11 @@ fn handle_room_list_service_loading_state(mut loading_state: Subscriber { enqueue_rooms_list_update(RoomsListUpdate::NotLoaded, false); + enqueue_rooms_list_update(RoomsListUpdate::NotLoaded, true); } RoomListLoadingState::Loaded { maximum_number_of_rooms } => { enqueue_rooms_list_update(RoomsListUpdate::LoadedRooms { max_rooms: maximum_number_of_rooms }, false); + enqueue_rooms_list_update(RoomsListUpdate::LoadedRooms { max_rooms: maximum_number_of_rooms }, true); } } }