Merge pull request #1695 from famedly/krille/use-records-check-homeserver

refactor: Use dart records for checkHomeserver method
This commit is contained in:
Krille-chan 2024-03-18 15:27:21 +01:00 committed by GitHub
commit db49f1e196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 18 deletions

View File

@ -460,7 +460,12 @@ class Client extends MatrixApi {
/// login types. Throws an exception if the server is not compatible with the /// login types. Throws an exception if the server is not compatible with the
/// client and sets [homeserver] to [homeserverUrl] if it is. Supports the /// client and sets [homeserver] to [homeserverUrl] if it is. Supports the
/// types `Uri` and `String`. /// types `Uri` and `String`.
Future<HomeserverSummary> checkHomeserver( Future<
(
DiscoveryInformation?,
GetVersionsResponse versions,
List<LoginFlow>,
)> checkHomeserver(
Uri homeserverUrl, { Uri homeserverUrl, {
bool checkWellKnown = true, bool checkWellKnown = true,
Set<String>? overrideSupportedVersions, Set<String>? overrideSupportedVersions,
@ -497,11 +502,7 @@ class Client extends MatrixApi {
loginTypes.map((f) => f.type ?? '').toSet(), supportedLoginTypes); loginTypes.map((f) => f.type ?? '').toSet(), supportedLoginTypes);
} }
return HomeserverSummary( return (wellKnown, versions, loginTypes);
discoveryInformation: wellKnown,
versions: versions,
loginFlows: loginTypes,
);
} catch (_) { } catch (_) {
homeserver = null; homeserver = null;
rethrow; rethrow;
@ -3458,18 +3459,6 @@ class FileTooBigMatrixException extends MatrixException {
'File size ${_formatFileSize(actualFileSize)} exceeds allowed maximum of ${_formatFileSize(maxFileSize)}'; 'File size ${_formatFileSize(actualFileSize)} exceeds allowed maximum of ${_formatFileSize(maxFileSize)}';
} }
class HomeserverSummary {
final DiscoveryInformation? discoveryInformation;
final GetVersionsResponse versions;
final List<LoginFlow> loginFlows;
HomeserverSummary({
required this.discoveryInformation,
required this.versions,
required this.loginFlows,
});
}
class ArchivedRoom { class ArchivedRoom {
final Room room; final Room room;
final Timeline timeline; final Timeline timeline;