fix: dedup /versions calls
This commit is contained in:
parent
5f85acb7f0
commit
d9681d552e
|
|
@ -93,6 +93,7 @@ class FakeMatrixApi extends BaseClient {
|
||||||
|
|
||||||
Set<String> servers = {
|
Set<String> servers = {
|
||||||
'https://fakeserver.notexisting',
|
'https://fakeserver.notexisting',
|
||||||
|
'https://fakeserver.notexisting:1337',
|
||||||
'https://fakeserverpriortoauthmedia.notexisting'
|
'https://fakeserverpriortoauthmedia.notexisting'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -526,7 +526,7 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if server supports at least one supported version
|
// Check if server supports at least one supported version
|
||||||
final versions = _versionsCache = await getVersions();
|
final versions = await getVersions();
|
||||||
if (!versions.versions
|
if (!versions.versions
|
||||||
.any((version) => supportedVersions.contains(version))) {
|
.any((version) => supportedVersions.contains(version))) {
|
||||||
throw BadServerVersionsException(
|
throw BadServerVersionsException(
|
||||||
|
|
@ -1199,10 +1199,11 @@ class Client extends MatrixApi {
|
||||||
_archivedRooms.add(ArchivedRoom(room: archivedRoom, timeline: timeline));
|
_archivedRooms.add(ArchivedRoom(room: archivedRoom, timeline: timeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
GetVersionsResponse? _versionsCache;
|
final _versionsCache =
|
||||||
|
AsyncCache<GetVersionsResponse>(const Duration(hours: 1));
|
||||||
|
|
||||||
Future<bool> authenticatedMediaSupported() async {
|
Future<bool> authenticatedMediaSupported() async {
|
||||||
final versionsResponse = _versionsCache ??= await getVersions();
|
final versionsResponse = await _versionsCache.fetch(() => getVersions());
|
||||||
return versionsResponse.versions.any(
|
return versionsResponse.versions.any(
|
||||||
(v) => isVersionGreaterThanOrEqualTo(v, 'v1.11'),
|
(v) => isVersionGreaterThanOrEqualTo(v, 'v1.11'),
|
||||||
) ||
|
) ||
|
||||||
|
|
@ -1870,7 +1871,12 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
_groupCallSessionId = randomAlpha(12);
|
_groupCallSessionId = randomAlpha(12);
|
||||||
|
|
||||||
|
/// while I would like to move these to a onLoginStateChanged stream listener
|
||||||
|
/// that might be too much overhead and you don't have any use of these
|
||||||
|
/// when you are logged out anyway. So we just invalidate them on next login
|
||||||
_serverConfigCache.invalidate();
|
_serverConfigCache.invalidate();
|
||||||
|
_versionsCache.invalidate();
|
||||||
|
|
||||||
final account = await this.database?.getClient(clientName);
|
final account = await this.database?.getClient(clientName);
|
||||||
newRefreshToken ??= account?.tryGet<String>('refresh_token');
|
newRefreshToken ??= account?.tryGet<String>('refresh_token');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue