Skip to content

Commit

Permalink
Ensure the rooms list is always freshly updated. (#51)
Browse files Browse the repository at this point in the history
Sometimes an `Event::Signal` gets lost (applied to a different event generation),
so we were missing them in the rooms_list event handler.
This manifested as some rooms failing to be displayed if they were discovered
after a user had clicked away from the rooms_list screen and then navigated
back to the screen.

Now, we check for updates to the rooms on every event handler,
which ensures we never miss any updates even if an `Event::Signal` was missed.
  • Loading branch information
kevinaboos authored Feb 23, 2024
1 parent cafc78b commit 3f94b3a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
58 changes: 29 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ metadata.makepad-auto-version = "zqpv-Yj-K7WNVK2I8h5Okhho46Q="


[dependencies]
# makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" }
makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "extend_portal_list_item_api" }
makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" }


anyhow = "1.0"
Expand Down
6 changes: 2 additions & 4 deletions src/home/rooms_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ pub struct RoomsList {

impl Widget for RoomsList {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
// Currently, a Signal event is only used to tell this widget
// that the rooms list has been updated in the background.
if let Event::Signal = event {
// Process all pending updates to the list of all rooms, and then redraw it.
// Process all pending updates to the list of all rooms, and then redraw it.
{
let mut num_updates: usize = 0;
while let Some(update) = PENDING_ROOM_UPDATES.pop() {
num_updates += 1;
Expand Down
1 change: 1 addition & 0 deletions src/sliding_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ async fn timeline_subscriber_handler(
) {
log!("Starting timeline subscriber for room {room_id}...");
let (mut timeline_items, mut subscriber) = timeline.subscribe_batched().await;
log!("Received initial timeline update for room {room_id}.");

sender.send(TimelineUpdate::NewItems {
items: timeline_items.clone(),
Expand Down

0 comments on commit 3f94b3a

Please sign in to comment.