Skip to content

Commit 3d78afe

Browse files
committed
Parameterize the ApiConnection in realm.dart.
1 parent 1c61170 commit 3d78afe

File tree

2 files changed

+163
-135
lines changed

2 files changed

+163
-135
lines changed

lib/api/route/realm.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ part 'realm.g.dart';
1616
// See thread, and the zulip-mobile code and chat thread it links to:
1717
// https://github.com/zulip/zulip-flutter/pull/55#discussion_r1160267577
1818
Future<GetServerSettingsResult> getServerSettings({
19-
required Uri realmUrl,
19+
required ApiConnection apiConnection,
2020
}) async {
2121
final Map<String, dynamic> data;
22-
// TODO make this function testable by taking ApiConnection from caller
23-
final connection = ApiConnection.live(realmUrl: realmUrl);
2422
try {
25-
data = await connection.get('server_settings', null);
23+
data = await apiConnection.get('server_settings', null);
2624
} finally {
27-
connection.close();
25+
apiConnection.close();
2826
}
2927

3028
return GetServerSettingsResult.fromJson(data);
@@ -67,7 +65,7 @@ class GetServerSettingsResult {
6765
});
6866

6967
factory GetServerSettingsResult.fromJson(Map<String, dynamic> json) =>
70-
_$GetServerSettingsResultFromJson(json);
68+
_$GetServerSettingsResultFromJson(json);
7169

7270
Map<String, dynamic> toJson() => _$GetServerSettingsResultToJson(this);
7371
}

0 commit comments

Comments
 (0)