@@ -4,14 +4,14 @@ use makepad_widgets::*;
44use matrix_sdk:: { ruma:: { events:: tag:: Tags , MilliSecondsSinceUnixEpoch , OwnedRoomAliasId , OwnedRoomId , OwnedUserId } , RoomState } ;
55use crate :: {
66 app:: { AppState , SelectedRoom } ,
7- room:: { room_display_filter:: { RoomDisplayFilter , RoomDisplayFilterBuilder , RoomFilterCriteria , SortFn } , RoomPreviewAvatar } ,
7+ room:: { room_display_filter:: { RoomDisplayFilter , RoomDisplayFilterBuilder , RoomFilterCriteria , SortFn } , FetchedRoomAvatar } ,
88 shared:: { collapsible_header:: { CollapsibleHeaderAction , CollapsibleHeaderWidgetRefExt , HeaderCategory } , jump_to_bottom_button:: UnreadMessageCount , popup_list:: { enqueue_popup_notification, PopupItem , PopupKind } , room_filter_input_bar:: RoomFilterAction } ,
99 sliding_sync:: { submit_async_request, MatrixRequest , PaginationDirection } , utils:: room_name_or_id,
1010} ;
11- use super :: room_preview :: RoomPreviewAction ;
11+ use super :: rooms_list_entry :: RoomsListEntryAction ;
1212
1313/// Whether to pre-paginate visible rooms at least once in order to
14- /// be able to display the latest message in the room preview ,
14+ /// be able to display the latest message in a room's RoomsListEntry ,
1515/// and to have something to immediately show when a user first opens a room.
1616const PREPAGINATE_VISIBLE_ROOMS : bool = true ;
1717
@@ -54,7 +54,7 @@ live_design! {
5454 use crate :: shared:: avatar:: Avatar ;
5555 use crate :: shared:: html_or_plaintext:: HtmlOrPlaintext ;
5656 use crate :: shared:: collapsible_header:: * ;
57- use crate :: home:: room_preview :: * ;
57+ use crate :: home:: rooms_list_entry :: * ;
5858
5959 StatusLabel = <View > {
6060 width: Fill , height: Fit ,
@@ -86,7 +86,7 @@ live_design! {
8686 flow: Down , spacing: 0.0
8787
8888 collapsible_header = <CollapsibleHeader > { }
89- room_preview = <RoomPreview > { }
89+ rooms_list_entry = <RoomsListEntry > { }
9090 empty = <View > { }
9191 status_label = <StatusLabel > { }
9292 bottom_filler = <View > {
@@ -137,7 +137,7 @@ pub enum RoomsListUpdate {
137137 /// Update the avatar (image) for the given room.
138138 UpdateRoomAvatar {
139139 room_id : OwnedRoomId ,
140- avatar : RoomPreviewAvatar ,
140+ avatar : FetchedRoomAvatar ,
141141 } ,
142142 /// Update whether the given room is a direct room.
143143 UpdateIsDirect {
@@ -218,10 +218,10 @@ pub struct JoinedRoomInfo {
218218 pub latest : Option < ( MilliSecondsSinceUnixEpoch , String ) > ,
219219 /// The avatar for this room: either an array of bytes holding the avatar image
220220 /// or a string holding the first Unicode character of the room name.
221- pub avatar : RoomPreviewAvatar ,
221+ pub avatar : FetchedRoomAvatar ,
222222 /// Whether this room has been paginated at least once.
223223 /// We pre-paginate visible rooms at least once in order to
224- /// be able to display the latest message in the room preview,
224+ /// be able to display the latest message in the RoomsListEntry
225225 /// and to have something to immediately show when a user first opens a room.
226226 pub has_been_paginated : bool ,
227227 /// Whether this room is currently selected in the UI.
@@ -247,7 +247,7 @@ pub struct InvitedRoomInfo {
247247 pub alt_aliases : Vec < OwnedRoomAliasId > ,
248248 /// The avatar for this room: either an array of bytes holding the avatar image
249249 /// or a string holding the first Unicode character of the room name.
250- pub room_avatar : RoomPreviewAvatar ,
250+ pub room_avatar : FetchedRoomAvatar ,
251251 /// Info about the user who invited us to this room, if available.
252252 pub inviter_info : Option < InviterInfo > ,
253253 /// The timestamp and Html text content of the latest message in this room.
@@ -309,7 +309,7 @@ pub struct RoomsList {
309309 /// This is a shared reference to the thread-local [`ALL_INVITED_ROOMS`] variable.
310310 #[ rust] invited_rooms : Rc < RefCell < HashMap < OwnedRoomId , InvitedRoomInfo > > > ,
311311
312- /// The set of all joined rooms and their cached preview info.
312+ /// The set of all joined rooms and their cached info.
313313 /// This includes both direct rooms and regular rooms.
314314 #[ rust] all_joined_rooms : HashMap < OwnedRoomId , JoinedRoomInfo > ,
315315
@@ -828,16 +828,6 @@ impl RoomsList {
828828 regular_rooms_indexes,
829829 )
830830 }
831-
832- /// Returns a room's avatar and displayable name.
833- pub fn get_room_avatar_and_name ( & self , room_id : & OwnedRoomId ) -> Option < ( RoomPreviewAvatar , Option < String > ) > {
834- self . all_joined_rooms . get ( room_id)
835- . map ( |room_info| ( room_info. avatar . clone ( ) , room_info. room_name . clone ( ) ) )
836- . or_else ( || {
837- self . invited_rooms . borrow ( ) . get ( room_id)
838- . map ( |room_info| ( room_info. room_avatar . clone ( ) , room_info. room_name . clone ( ) ) )
839- } )
840- }
841831}
842832
843833impl Widget for RoomsList {
@@ -856,7 +846,7 @@ impl Widget for RoomsList {
856846 |cx| self . view . handle_event ( cx, event, & mut Scope :: with_props ( & props) )
857847 ) ;
858848 for list_action in list_actions {
859- if let RoomPreviewAction :: Clicked ( clicked_room_id) = list_action. as_widget_action ( ) . cast ( ) {
849+ if let RoomsListEntryAction :: Clicked ( clicked_room_id) = list_action. as_widget_action ( ) . cast ( ) {
860850 let new_selected_room = if let Some ( jr) = self . all_joined_rooms . get ( & clicked_room_id) {
861851 SelectedRoom :: JoinedRoom {
862852 room_id : jr. room_id . clone ( ) . into ( ) ,
@@ -970,10 +960,10 @@ impl Widget for RoomsList {
970960 else if let Some ( invited_room_id) = get_invited_room_id ( portal_list_index) {
971961 let mut invited_rooms_mut = self . invited_rooms . borrow_mut ( ) ;
972962 if let Some ( invited_room) = invited_rooms_mut. get_mut ( invited_room_id) {
973- let item = list. item ( cx, portal_list_index, live_id ! ( room_preview ) ) ;
963+ let item = list. item ( cx, portal_list_index, live_id ! ( rooms_list_entry ) ) ;
974964 invited_room. is_selected =
975965 self . current_active_room . as_deref ( ) == Some ( invited_room_id) ;
976- // Pass the room info down to the RoomPreview widget via Scope.
966+ // Pass the room info down to the RoomsListEntry widget via Scope.
977967 scope = Scope :: with_props ( & * invited_room) ;
978968 item. draw_all ( cx, & mut scope) ;
979969 } else {
@@ -995,7 +985,7 @@ impl Widget for RoomsList {
995985 }
996986 else if let Some ( direct_room_id) = get_direct_room_id ( portal_list_index) {
997987 if let Some ( direct_room) = self . all_joined_rooms . get_mut ( direct_room_id) {
998- let item = list. item ( cx, portal_list_index, live_id ! ( room_preview ) ) ;
988+ let item = list. item ( cx, portal_list_index, live_id ! ( rooms_list_entry ) ) ;
999989 direct_room. is_selected =
1000990 self . current_active_room . as_ref ( ) == Some ( direct_room_id) ;
1001991
@@ -1008,7 +998,7 @@ impl Widget for RoomsList {
1008998 direction : PaginationDirection :: Backwards ,
1009999 } ) ;
10101000 }
1011- // Pass the room info down to the RoomPreview widget via Scope.
1001+ // Pass the room info down to the RoomsListEntry widget via Scope.
10121002 scope = Scope :: with_props ( & * direct_room) ;
10131003 item. draw_all ( cx, & mut scope) ;
10141004 } else {
@@ -1030,7 +1020,7 @@ impl Widget for RoomsList {
10301020 }
10311021 else if let Some ( regular_room_id) = get_regular_room_id ( portal_list_index) {
10321022 if let Some ( regular_room) = self . all_joined_rooms . get_mut ( regular_room_id) {
1033- let item = list. item ( cx, portal_list_index, live_id ! ( room_preview ) ) ;
1023+ let item = list. item ( cx, portal_list_index, live_id ! ( rooms_list_entry ) ) ;
10341024 regular_room. is_selected =
10351025 self . current_active_room . as_ref ( ) == Some ( regular_room_id) ;
10361026
@@ -1043,7 +1033,7 @@ impl Widget for RoomsList {
10431033 direction : PaginationDirection :: Backwards ,
10441034 } ) ;
10451035 }
1046- // Pass the room info down to the RoomPreview widget via Scope.
1036+ // Pass the room info down to the RoomsListEntry widget via Scope.
10471037 scope = Scope :: with_props ( & * regular_room) ;
10481038 item. draw_all ( cx, & mut scope) ;
10491039 } else {
@@ -1087,13 +1077,8 @@ impl RoomsListRef {
10871077 } ;
10881078 inner. is_room_loaded ( room_id)
10891079 }
1090-
1091- /// See [`RoomsList::get_room_avatar_and_name()`].
1092- pub fn get_room_avatar_and_name ( & self , room_id : & OwnedRoomId ) -> Option < ( RoomPreviewAvatar , Option < String > ) > {
1093- let inner = self . borrow ( ) ?;
1094- inner. get_room_avatar_and_name ( room_id)
1095- }
10961080}
1081+
10971082pub struct RoomsListScopeProps {
10981083 /// Whether the RoomsList's inner PortalList was scrolling
10991084 /// when the latest finger down event occurred.
0 commit comments