mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 09:16:54 +00:00
chore: Transfer some methords from api to provider
This commit is contained in:
parent
4d4a980aaf
commit
efe4f620ee
|
@ -113,22 +113,21 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
}
|
||||
|
||||
Future<List<ServerProviderLocation>> fetchAvailableLocations() async {
|
||||
if (ApiController.currentServerProviderApiFactory == null) {
|
||||
if (ProvidersController.currentServerProvider == null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final APIGenericResult apiResult = await ApiController
|
||||
.currentServerProviderApiFactory!
|
||||
.getServerProvider()
|
||||
final APIGenericResult apiResponse = await ProvidersController
|
||||
.currentServerProvider!
|
||||
.getAvailableLocations();
|
||||
|
||||
if (!apiResult.success) {
|
||||
if (!apiResponse.success) {
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
'initializing.could_not_connect'.tr(),
|
||||
);
|
||||
}
|
||||
|
||||
return apiResult.data;
|
||||
return apiResponse.data;
|
||||
}
|
||||
|
||||
Future<List<ServerType>> fetchAvailableTypesByLocation(
|
||||
|
@ -138,10 +137,9 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
return [];
|
||||
}
|
||||
|
||||
final APIGenericResult apiResult = await ApiController
|
||||
.currentServerProviderApiFactory!
|
||||
.getServerProvider()
|
||||
.getServerTypesByLocation(location: location);
|
||||
final APIGenericResult apiResult = await ProvidersController
|
||||
.currentServerProvider!
|
||||
.getServerTypes(location: location);
|
||||
|
||||
if (!apiResult.success) {
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
import 'package:selfprivacy/logic/api_maps/api_generic_result.dart';
|
||||
import 'package:selfprivacy/logic/models/server_provider_location.dart';
|
||||
import 'package:selfprivacy/logic/models/server_type.dart';
|
||||
|
||||
abstract class ServerProvider {
|
||||
Future<APIGenericResult<bool>> isApiTokenValid(final String apiToken);
|
||||
Future<APIGenericResult<List<ServerProviderLocation>>>
|
||||
getAvailableLocations();
|
||||
Future<APIGenericResult<List<ServerType>>> getServerTypes({
|
||||
required final ServerProviderLocation location,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue