1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-16 12:20:08 +02:00
immich/mobile/lib/shared/services/server_info.service.dart
xpwmaosldk d02b97e1c1
Add service provider (#250)
* optimize android side gradle settings

* android minsdk back to 21

* remove unused package, update linter and fix lint error

* clean code of 'shared module' with offical dart style guide

* restore uploadProfileImage method in UserService

* add service provider

* fix searchFocusNode init error
2022-06-25 13:46:51 -05:00

34 lines
1.0 KiB
Dart

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/models/server_info.model.dart';
import 'package:immich_mobile/shared/models/server_version.model.dart';
import 'package:immich_mobile/shared/services/network.service.dart';
final serverInfoServiceProvider =
Provider((ref) => ServerInfoService(ref.watch(networkServiceProvider)));
class ServerInfoService {
final NetworkService _networkService;
ServerInfoService(this._networkService);
Future<ServerInfo> getServerInfo() async {
Response response = await _networkService.getRequest(url: 'server-info');
return ServerInfo.fromJson(response.toString());
}
Future<ServerVersion?> getServerVersion() async {
try {
Response response =
await _networkService.getRequest(url: 'server-info/version');
return ServerVersion.fromJson(response.toString());
} catch (e) {
debugPrint("Error getting server info");
}
return null;
}
}