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) {
424 } 424 }
425} 425}
426 426
427async fn refresh_rooms(client: &Client, store: &AsyncProgramStore) { 427async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: bool) {
428 let mut names = vec![]; 428 let mut names = vec![];
429 429
430 let mut spaces = vec![]; 430 let mut spaces = vec![];
@@ -432,7 +432,18 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore) {
432 let mut dms = vec![]; 432 let mut dms = vec![];
433 433
434 for room in client.invited_rooms().into_iter().chain(client.joined_rooms().into_iter()) { 434 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();
436 let tags = room.tags().await.unwrap_or_default(); 447 let tags = room.tags().await.unwrap_or_default();
437 448
438 names.push((room.room_id().to_owned(), name)); 449 names.push((room.room_id().to_owned(), name));
@@ -460,7 +471,7 @@ async fn refresh_rooms_forever(client: &Client, store: &AsyncProgramStore) {
460 let mut interval = tokio::time::interval(Duration::from_secs(5)); 471 let mut interval = tokio::time::interval(Duration::from_secs(5));
461 472
462 loop { 473 loop {
463 refresh_rooms(client, store).await; 474 refresh_rooms(client, store, false).await;
464 interval.tick().await; 475 interval.tick().await;
465 } 476 }
466} 477}
@@ -663,7 +674,7 @@ pub async fn do_first_sync(client: &Client, store: &AsyncProgramStore) -> Result
663 client.send_queue().respawn_tasks_for_rooms_with_unsent_requests().await; 674 client.send_queue().respawn_tasks_for_rooms_with_unsent_requests().await;
664 675
665 // Populate sync_info with our initial set of rooms/dms/spaces. 676 // Populate sync_info with our initial set of rooms/dms/spaces.
666 refresh_rooms(client, store).await; 677 refresh_rooms(client, store, true).await;
667 678
668 // Insert Need::Messages to fetch accurate recent timestamps in the background. 679 // Insert Need::Messages to fetch accurate recent timestamps in the background.
669 let mut locked = store.lock().await; 680 let mut locked = store.lock().await;