Skip to content

Commit

Permalink
Call hide_timeline() upon a RoomScreen widget instance being dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinaboos committed Oct 11, 2024
1 parent 36a1116 commit 46c99a6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,9 +1003,12 @@ pub struct RoomScreen {

impl Drop for RoomScreen {
fn drop(&mut self) {
// Make sure to return the room state back to TIMELINE_STATES, so that other RoomScreen instances can access it.
// RoomScreen is dropped whenever a tab is closed or the app is resized to a different AdaptiveView layout.
self.save_state();
// This ensures that the `TimelineUiState` instance owned by this room is *always* returned
// back to to `TIMELINE_STATES`, which ensures that its UI state(s) are not lost
// and that other RoomScreen instances can show this room in the future.
// RoomScreen will be dropped whenever its widget instance is destroyed, e.g.,
// when a Tab is closed or the app is resized to a different AdaptiveView layout.
self.hide_timeline();
}
}

Expand Down Expand Up @@ -1820,8 +1823,7 @@ impl RoomScreen {
self.redraw(cx);
}

/// Invoke this when this timeline is being hidden or no longer being shown,
/// e.g., when the user navigates away from this timeline.
/// Invoke this when this RoomScreen/timeline is being hidden or no longer being shown.
fn hide_timeline(&mut self) {
if let Some(room_id) = self.room_id.clone() {
self.save_state();
Expand Down

0 comments on commit 46c99a6

Please sign in to comment.