Commit af9dd52da0

af9dd52da0260388119557502848aa836639537a

parent: a5e0ed3a4d

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-08-31 01:22 UTC
committer: <noreply@github.com>

Force room names to be fetched in the background when none are cached (#657)

Layout: unified · split

src/worker.rs +15 −4
@@ -424,7 +424,7 @@ async fn load_older_forever(client: &Client, store: &AsyncProgramStore) {
424424 }
425425}
426426
427async fn refresh_rooms(client: &Client, store: &AsyncProgramStore) {
427async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: bool) {
428428 let mut names = vec![];
429429
430430 let mut spaces = vec![];
@@ -432,7 +432,18 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore) {
432432 let mut dms = vec![];
433433
434434 for room in client.invited_rooms().into_iter().chain(client.joined_rooms().into_iter()) {
435 let name = room.cached_display_name().unwrap_or(RoomDisplayName::Empty).to_string();
435 let display = if let Some(name) = room.cached_display_name() {
436 name
437 } else if !first_sync && let Ok(name) = room.display_name().await {
438 // If we are not trying to fill out the SyncInfo during startup,
439 // then we can take our time here and force room information
440 // to be loaded.
441 name
442 } else {
443 RoomDisplayName::Empty
444 };
445
446 let name = display.to_string();
436447 let tags = room.tags().await.unwrap_or_default();
437448
438449 names.push((room.room_id().to_owned(), name));
@@ -460,7 +471,7 @@ async fn refresh_rooms_forever(client: &Client, store: &AsyncProgramStore) {
460471 let mut interval = tokio::time::interval(Duration::from_secs(5));
461472
462473 loop {
463 refresh_rooms(client, store).await;
474 refresh_rooms(client, store, false).await;
464475 interval.tick().await;
465476 }
466477}
@@ -663,7 +674,7 @@ pub async fn do_first_sync(client: &Client, store: &AsyncProgramStore) -> Result
663674 client.send_queue().respawn_tasks_for_rooms_with_unsent_requests().await;
664675
665676 // Populate sync_info with our initial set of rooms/dms/spaces.
666 refresh_rooms(client, store).await;
677 refresh_rooms(client, store, true).await;
667678
668679 // Insert Need::Messages to fetch accurate recent timestamps in the background.
669680 let mut locked = store.lock().await;