Skip to content

Commit f61ba4f

Browse files
committed
fix(ui): Don't do a authenticated /versions call when building the roomlist service
1 parent 9a3857d commit f61ba4f

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

crates/matrix-sdk-ui/src/room_list_service/mod.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use eyeball::Subscriber;
6363
use futures_util::{Stream, StreamExt, pin_mut};
6464
use matrix_sdk::{
6565
Client, Error as SlidingSyncError, Room, SlidingSync, SlidingSyncList, SlidingSyncMode,
66-
event_cache::EventCacheError, timeout::timeout,
66+
config::RequestConfig, event_cache::EventCacheError, timeout::timeout,
6767
};
6868
pub use room_list::*;
6969
use ruma::{
@@ -158,11 +158,26 @@ impl RoomListService {
158158
}));
159159

160160
if client.enabled_thread_subscriptions() {
161-
let server_features = client
162-
.supported_versions()
161+
let server_features = if let Some(cached) = client
162+
.supported_versions_cached()
163163
.await
164-
.map_err(|err| Error::SlidingSync(err.into()))?
165-
.features;
164+
.map_err(|e| Error::SlidingSync(e.into()))?
165+
{
166+
cached.features
167+
} else {
168+
// Our `/versions` calls don't support token refresh as of now (11.11.2025), so
169+
// we're going to skip the sending of the authentication headers in case they
170+
// might have expired.
171+
//
172+
// We only care about a feature which is advertised without being authenticaded
173+
// anyways.
174+
client
175+
.fetch_server_versions(Some(RequestConfig::new().skip_auth()))
176+
.await
177+
.map_err(|e| Error::SlidingSync(e.into()))?
178+
.as_supported_versions()
179+
.features
180+
};
166181

167182
if !server_features.contains(&FeatureFlag::from("org.matrix.msc4306")) {
168183
warn!(

crates/matrix-sdk-ui/tests/integration/room_list_service.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2906,7 +2906,12 @@ async fn test_thread_subscriptions_extension_enabled_only_if_server_advertises_i
29062906
.mock_versions()
29072907
.ok_custom(&["v1.11"], &features_map)
29082908
.named("/versions, first time")
2909-
.mock_once()
2909+
// This used to be a `mock_once()`, but we're not caching the versions in the
2910+
// `RoomListService::new()` method anymore, so we're now doing a couple more requests
2911+
// for this. The sync will want to know about the `/versions` once it tries to build
2912+
// the request path.
2913+
.up_to_n_times(3)
2914+
.expect(3..)
29102915
.mount()
29112916
.await;
29122917

0 commit comments

Comments
 (0)