diff --git a/crates/matrix-sdk-ui/src/room_list_service/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/mod.rs index b26ca1301..610e80d67 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/mod.rs @@ -63,7 +63,7 @@ use eyeball::Subscriber; use futures_util::{Stream, StreamExt, pin_mut}; use matrix_sdk::{ Client, Error as SlidingSyncError, Room, SlidingSync, SlidingSyncList, SlidingSyncMode, - event_cache::EventCacheError, timeout::timeout, + config::RequestConfig, event_cache::EventCacheError, timeout::timeout, }; pub use room_list::*; use ruma::{ @@ -158,11 +158,26 @@ impl RoomListService { })); if client.enabled_thread_subscriptions() { - let server_features = client - .supported_versions() + let server_features = if let Some(cached) = client + .supported_versions_cached() .await - .map_err(|err| Error::SlidingSync(err.into()))? - .features; + .map_err(|e| Error::SlidingSync(e.into()))? + { + cached.features + } else { + // Our `/versions` calls don't support token refresh as of now (11.11.2025), so + // we're going to skip the sending of the authentication headers in case they + // might have expired. + // + // We only care about a feature which is advertised without being authenticaded + // anyways. + client + .fetch_server_versions(Some(RequestConfig::new().skip_auth())) + .await + .map_err(|e| Error::SlidingSync(e.into()))? + .as_supported_versions() + .features + }; if !server_features.contains(&FeatureFlag::from("org.matrix.msc4306")) { warn!( diff --git a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs index 3e47c66e3..ca3e3efbb 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs @@ -2906,7 +2906,12 @@ async fn test_thread_subscriptions_extension_enabled_only_if_server_advertises_i .mock_versions() .ok_custom(&["v1.11"], &features_map) .named("/versions, first time") - .mock_once() + // This used to be a `mock_once()`, but we're not caching the versions in the + // `RoomListService::new()` method anymore, so we're now doing a couple more requests + // for this. The sync will want to know about the `/versions` once it tries to build + // the request path. + .up_to_n_times(3) + .expect(3..) .mount() .await;