@@ -34,7 +34,7 @@ use crate::shared::mentionable_text_input::MentionableTextInputWidgetRefExt;
34
34
35
35
use rangemap:: RangeSet ;
36
36
37
- use super :: { editing_pane:: { EditingPaneAction , EditingPaneWidgetExt } , event_reaction_list:: ReactionData , loading_pane:: LoadingPaneRef , new_message_context_menu:: { MessageAbilities , MessageDetails } , room_read_receipt:: { self , populate_read_receipts, MAX_VISIBLE_AVATARS_IN_READ_RECEIPT } } ;
37
+ use super :: { editing_pane:: { EditingPaneAction , EditingPaneWidgetExt } , event_reaction_list:: ReactionData , loading_pane:: LoadingPaneRef , new_message_context_menu:: { MessageAbilities , MessageDetails } , room_read_receipt:: { self , populate_read_receipts, MAX_VISIBLE_AVATARS_IN_READ_RECEIPT } , rooms_list :: RoomsListWidgetExt } ;
38
38
39
39
const GEO_URI_SCHEME : & str = "geo:" ;
40
40
@@ -63,6 +63,7 @@ live_design! {
63
63
use crate :: home:: event_reaction_list:: * ;
64
64
use crate :: home:: editing_pane:: * ;
65
65
use crate :: room:: room_input_bar:: * ;
66
+ use crate :: rooms_list:: * ;
66
67
67
68
IMG_DEFAULT_AVATAR = dep( "crate://self/resources/img/default_avatar.png" )
68
69
@@ -722,7 +723,11 @@ live_design! {
722
723
draw_bg: {
723
724
color: ( COLOR_PRIMARY_DARKER )
724
725
}
725
-
726
+ // Used to retreive the list of loaded rooms.
727
+ <CachedWidget > {
728
+ width: 0 , height: 0 ,
729
+ rooms_list = <RoomsList > { }
730
+ }
726
731
restore_status_label = <Label > {
727
732
align: { x: 0.0 , y: 0.5 } ,
728
733
padding: { left: 5.0 , right: 0.0 }
@@ -930,10 +935,6 @@ pub struct RoomScreen {
930
935
#[ rust] room_name : String ,
931
936
/// The persistent UI-relevant states for the room that this widget is currently displaying.
932
937
#[ rust] tl_state : Option < TimelineUiState > ,
933
- /// The status of this room being restored from previously-saved data in storage.
934
- /// If `Pending` or `AllRoomsLoaded`, this RoomScreen will display a message;
935
- /// otherwise, the regular RoomScreen content (the room timeline) will be shown.
936
- #[ rust] restore_status : RoomsPanelRestoreAction ,
937
938
}
938
939
impl Drop for RoomScreen {
939
940
fn drop ( & mut self ) {
@@ -957,6 +958,23 @@ impl Widget for RoomScreen {
957
958
// Currently, a Signal event is only used to tell this widget
958
959
// that its timeline events have been updated in the background.
959
960
if let Event :: Signal = event {
961
+ if let Some ( room_id) = & self . room_id {
962
+ let rooms_list = self . rooms_list ( id ! ( rooms_list) ) ;
963
+ if !rooms_list. is_room_loaded ( room_id) {
964
+ let status_text = if rooms_list. all_known_rooms_loaded ( ) {
965
+ format ! (
966
+ "Room {} was not found in the homeserver's list of all rooms." ,
967
+ self . room_name
968
+ )
969
+ } else {
970
+ "[Placeholder for Spinner]" . to_string ( )
971
+ } ;
972
+ self . view
973
+ . label ( id ! ( restore_status_label) )
974
+ . set_text ( cx, & status_text) ;
975
+ return ;
976
+ }
977
+ }
960
978
self . process_timeline_updates ( cx, & portal_list) ;
961
979
962
980
// Ideally we would do this elsewhere on the main thread, because it's not room-specific,
@@ -965,6 +983,7 @@ impl Widget for RoomScreen {
965
983
// and wrap it in a `if let Event::Signal` conditional.
966
984
user_profile_cache:: process_user_profile_updates ( cx) ;
967
985
avatar_cache:: process_avatar_updates ( cx) ;
986
+
968
987
}
969
988
970
989
if let Event :: Actions ( actions) = event {
@@ -1037,16 +1056,14 @@ impl Widget for RoomScreen {
1037
1056
match action. downcast_ref ( ) {
1038
1057
Some ( RoomsPanelRestoreAction :: Success ( room_id) ) => {
1039
1058
if self . room_id . as_ref ( ) . is_some_and ( |r| r == room_id) {
1040
- self . set_restore_status ( cx, RoomsPanelRestoreAction :: Success ( room_id. clone ( ) ) ) ;
1041
1059
// Reset room_id before displaying room.
1042
1060
self . room_id = None ;
1043
1061
self . set_displayed_room ( cx, room_id. clone ( ) , self . room_name . clone ( ) ) ;
1062
+ self . view
1063
+ . label ( id ! ( restore_status_label) ) . set_text ( cx, "" ) ;
1044
1064
return ;
1045
1065
}
1046
1066
}
1047
- Some ( RoomsPanelRestoreAction :: AllRoomsLoaded ) => {
1048
- self . set_restore_status ( cx, RoomsPanelRestoreAction :: AllRoomsLoaded ) ;
1049
- }
1050
1067
_ => { }
1051
1068
}
1052
1069
// Handle the highlight animation.
@@ -1295,11 +1312,10 @@ impl Widget for RoomScreen {
1295
1312
}
1296
1313
1297
1314
fn draw_walk ( & mut self , cx : & mut Cx2d , scope : & mut Scope , walk : Walk ) -> DrawStep {
1298
- if matches ! (
1299
- & self . restore_status,
1300
- RoomsPanelRestoreAction :: Pending ( _) | RoomsPanelRestoreAction :: AllRoomsLoaded
1301
- ) {
1302
- return self . view . draw_walk ( cx, scope, walk) ;
1315
+ if let Some ( room_id) = & self . room_id {
1316
+ if !self . rooms_list ( id ! ( rooms_list) ) . is_room_loaded ( room_id) {
1317
+ return self . view . draw_walk ( cx, scope, walk) ;
1318
+ }
1303
1319
}
1304
1320
1305
1321
if self . tl_state . is_none ( ) {
@@ -2280,12 +2296,6 @@ impl RoomScreen {
2280
2296
fn show_timeline ( & mut self , cx : & mut Cx ) {
2281
2297
let room_id = self . room_id . clone ( )
2282
2298
. expect ( "BUG: Timeline::show_timeline(): no room_id was set." ) ;
2283
- // just an optional sanity check
2284
- // Remove this as there is restoring state RoomsPanelRestoreAction::Pending with early return
2285
- // assert!(self.tl_state.is_none(),
2286
- // "BUG: tried to show_timeline() into a timeline with existing state. \
2287
- // Did you forget to save the timeline state back to the global map of states?",
2288
- // );
2289
2299
2290
2300
// Obtain the current user's power levels for this room.
2291
2301
submit_async_request ( MatrixRequest :: GetRoomPowerLevels { room_id : room_id. clone ( ) } ) ;
@@ -2295,7 +2305,6 @@ impl RoomScreen {
2295
2305
( existing, false )
2296
2306
} else {
2297
2307
let Some ( ( update_sender, update_receiver, request_sender) ) = take_timeline_endpoints ( & room_id) else {
2298
- self . set_restore_status ( cx, RoomsPanelRestoreAction :: Pending ( room_id. clone ( ) ) ) ;
2299
2308
return ;
2300
2309
} ;
2301
2310
let new_tl_state = TimelineUiState {
@@ -2484,36 +2493,6 @@ impl RoomScreen {
2484
2493
self . show_timeline ( cx) ;
2485
2494
}
2486
2495
2487
- /// This sets the RoomScreen widget to display a text label in place of the timeline.
2488
- pub fn set_restore_status ( & mut self , cx : & mut Cx , status : RoomsPanelRestoreAction ) {
2489
- match & status {
2490
- RoomsPanelRestoreAction :: Pending ( room_id) => {
2491
- // Set this RoomScreen's room_id such that it can handle a `RoomsPanelRestoreAction::Success` action.
2492
- self . room_id = Some ( room_id. clone ( ) ) ;
2493
- self . view
2494
- . label ( id ! ( restore_status_label) )
2495
- . set_text ( cx, "[Placeholder for Spinner]" ) ;
2496
- self . restore_status = status;
2497
- }
2498
- RoomsPanelRestoreAction :: AllRoomsLoaded => {
2499
- if let RoomsPanelRestoreAction :: Pending ( _) = self . restore_status {
2500
- self . view . label ( id ! ( restore_status_label) ) . set_text (
2501
- cx,
2502
- & format ! (
2503
- "Room {} was not found in the homeserver's list of all rooms." ,
2504
- self . room_name
2505
- ) ,
2506
- ) ;
2507
- }
2508
- }
2509
- _ => {
2510
- self . view . label ( id ! ( restore_status_label) ) . set_text ( cx, "" ) ;
2511
- self . restore_status = status;
2512
- }
2513
- }
2514
- self . redraw ( cx) ;
2515
- }
2516
-
2517
2496
/// Sends read receipts based on the current scroll position of the timeline.
2518
2497
fn send_user_read_receipts_based_on_scroll_pos (
2519
2498
& mut self ,
@@ -2624,13 +2603,6 @@ impl RoomScreenRef {
2624
2603
let Some ( mut inner) = self . borrow_mut ( ) else { return } ;
2625
2604
inner. set_displayed_room ( cx, room_id, room_name) ;
2626
2605
}
2627
-
2628
- /// See [`RoomScreen::set_restore_status()`].
2629
- pub fn set_restore_status ( & self , cx : & mut Cx , status : RoomsPanelRestoreAction ) {
2630
- if let Some ( mut inner) = self . borrow_mut ( ) {
2631
- inner. set_restore_status ( cx, status) ;
2632
- }
2633
- }
2634
2606
}
2635
2607
2636
2608
/// Actions for the room screen's tooltip.
0 commit comments