mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2025-12-24 00:01:03 -05:00
fix(ui): Don't do a authenticated /versions call when building the roomlist service
This commit is contained in:
@@ -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!(
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user