From 4e3e7d9ccc950c5fb041e6a5f7383264346eacd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ku=C3=9Fowski?= Date: Sun, 9 Nov 2025 13:38:00 +0100 Subject: [PATCH] chore: Cache auth metadata response in client This is helpful for oidc and a requirement for implementing soft logout with oidc. --- lib/src/client.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index de0fb683..cd88d55c 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -132,7 +132,7 @@ class Client extends MatrixApi { @override set homeserver(Uri? homeserver) { if (this.homeserver != null && homeserver?.host != this.homeserver?.host) { - _wellKnown = null; + _wellKnown = _getAuthMetadataResponseCache = null; } super.homeserver = homeserver; } @@ -741,6 +741,12 @@ class Client extends MatrixApi { return response; } + GetAuthMetadataResponse? _getAuthMetadataResponseCache; + + @override + Future getAuthMetadata() async => + _getAuthMetadataResponseCache ??= await super.getAuthMetadata(); + /// Sends a logout command to the homeserver and clears all local data, /// including all persistent data from the store. @override