Merge pull request #2184 from famedly/krille/cache-auth-metadata

chore: Cache auth metadata response in client
This commit is contained in:
Karthikeyan Sankaran 2025-11-10 20:30:46 +05:30 committed by GitHub
commit c839b95e31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -132,7 +132,7 @@ class Client extends MatrixApi {
@override @override
set homeserver(Uri? homeserver) { set homeserver(Uri? homeserver) {
if (this.homeserver != null && homeserver?.host != this.homeserver?.host) { if (this.homeserver != null && homeserver?.host != this.homeserver?.host) {
_wellKnown = null; _wellKnown = _getAuthMetadataResponseCache = null;
} }
super.homeserver = homeserver; super.homeserver = homeserver;
} }
@ -741,6 +741,12 @@ class Client extends MatrixApi {
return response; return response;
} }
GetAuthMetadataResponse? _getAuthMetadataResponseCache;
@override
Future<GetAuthMetadataResponse> getAuthMetadata() async =>
_getAuthMetadataResponseCache ??= await super.getAuthMetadata();
/// Sends a logout command to the homeserver and clears all local data, /// Sends a logout command to the homeserver and clears all local data,
/// including all persistent data from the store. /// including all persistent data from the store.
@override @override