Skip to content

Commit 6f86c2f

Browse files
authored
chore(mobile): use sdk to for ping endpoint (immich-app#13218)
1 parent 4bb42c4 commit 6f86c2f

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

mobile/lib/services/api.service.dart

+2-16
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,13 @@ class ApiService implements Authentication {
9797
}
9898

9999
Future<bool> _isEndpointAvailable(String serverUrl) async {
100-
final Client client = Client();
101-
102100
if (!serverUrl.endsWith('/api')) {
103101
serverUrl += '/api';
104102
}
105103

106104
try {
107-
final response = await client
108-
.get(
109-
Uri.parse("$serverUrl/server-info/ping"),
110-
headers: getRequestHeaders(),
111-
)
112-
.timeout(const Duration(seconds: 5));
113-
114-
_log.info("Pinging server with response code ${response.statusCode}");
115-
if (response.statusCode != 200) {
116-
_log.severe(
117-
"Server Gateway Error: ${response.body} - Cannot communicate to the server",
118-
);
119-
return false;
120-
}
105+
await setEndpoint(serverUrl);
106+
await serverInfoApi.pingServer().timeout(Duration(seconds: 5));
121107
} on TimeoutException catch (_) {
122108
return false;
123109
} on SocketException catch (_) {

0 commit comments

Comments
 (0)