2022-06-11 23:12:06 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-06-25 20:46:51 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2022-08-03 07:04:34 +02:00
|
|
|
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
2022-07-13 14:23:48 +02:00
|
|
|
import 'package:immich_mobile/shared/services/api.service.dart';
|
|
|
|
import 'package:openapi/api.dart';
|
2022-02-03 18:06:44 +02:00
|
|
|
|
2022-07-13 14:23:48 +02:00
|
|
|
final serverInfoServiceProvider = Provider(
|
|
|
|
(ref) => ServerInfoService(
|
|
|
|
ref.watch(apiServiceProvider),
|
|
|
|
),
|
|
|
|
);
|
2022-06-25 20:46:51 +02:00
|
|
|
|
2022-02-03 18:06:44 +02:00
|
|
|
class ServerInfoService {
|
2022-07-13 14:23:48 +02:00
|
|
|
final ApiService _apiService;
|
2022-08-03 07:04:34 +02:00
|
|
|
|
2022-07-13 14:23:48 +02:00
|
|
|
ServerInfoService(this._apiService);
|
2022-02-03 18:06:44 +02:00
|
|
|
|
2022-07-13 14:23:48 +02:00
|
|
|
Future<ServerInfoResponseDto?> getServerInfo() async {
|
|
|
|
try {
|
|
|
|
return await _apiService.serverInfoApi.getServerInfo();
|
|
|
|
} catch (e) {
|
|
|
|
debugPrint("Error [getServerInfo] ${e.toString()}");
|
|
|
|
return null;
|
|
|
|
}
|
2022-02-03 18:06:44 +02:00
|
|
|
}
|
2022-03-11 00:09:03 +02:00
|
|
|
|
2022-07-13 14:23:48 +02:00
|
|
|
Future<ServerVersionReponseDto?> getServerVersion() async {
|
2022-06-11 23:12:06 +02:00
|
|
|
try {
|
2022-07-13 14:23:48 +02:00
|
|
|
return await _apiService.serverInfoApi.getServerVersion();
|
2022-06-11 23:12:06 +02:00
|
|
|
} catch (e) {
|
|
|
|
debugPrint("Error getting server info");
|
2022-07-13 14:23:48 +02:00
|
|
|
return null;
|
2022-06-11 23:12:06 +02:00
|
|
|
}
|
2022-03-22 08:22:04 +02:00
|
|
|
}
|
2022-02-03 18:06:44 +02:00
|
|
|
}
|