From 2456a64f37f363adc1e6db1119c9b69912d3faca Mon Sep 17 00:00:00 2001 From: Krille Date: Wed, 24 Jan 2024 14:59:55 +0100 Subject: [PATCH] refactor: Use dart records for checkHomeserver method This makes use of dart records to return three different values for one method. This makes the special class no longer necessary just for returning data. --- lib/src/client.dart | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 36cf5744..60d54b21 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -460,7 +460,12 @@ class Client extends MatrixApi { /// login types. Throws an exception if the server is not compatible with the /// client and sets [homeserver] to [homeserverUrl] if it is. Supports the /// types `Uri` and `String`. - Future checkHomeserver( + Future< + ( + DiscoveryInformation?, + GetVersionsResponse versions, + List, + )> checkHomeserver( Uri homeserverUrl, { bool checkWellKnown = true, Set? overrideSupportedVersions, @@ -497,11 +502,7 @@ class Client extends MatrixApi { loginTypes.map((f) => f.type ?? '').toSet(), supportedLoginTypes); } - return HomeserverSummary( - discoveryInformation: wellKnown, - versions: versions, - loginFlows: loginTypes, - ); + return (wellKnown, versions, loginTypes); } catch (_) { homeserver = null; rethrow; @@ -3458,18 +3459,6 @@ class FileTooBigMatrixException extends MatrixException { 'File size ${_formatFileSize(actualFileSize)} exceeds allowed maximum of ${_formatFileSize(maxFileSize)}'; } -class HomeserverSummary { - final DiscoveryInformation? discoveryInformation; - final GetVersionsResponse versions; - final List loginFlows; - - HomeserverSummary({ - required this.discoveryInformation, - required this.versions, - required this.loginFlows, - }); -} - class ArchivedRoom { final Room room; final Timeline timeline;