mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-11 18:39:45 +00:00
feat: Implement distinction for connection errors on server type page
Now user gets notified when connection error occurs
This commit is contained in:
parent
bd33b8d679
commit
1df5f6594d
|
@ -709,7 +709,8 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<ServerProviderLocation>> getAvailableLocations() async {
|
Future<APIGenericResult<List<ServerProviderLocation>>>
|
||||||
|
getAvailableLocations() async {
|
||||||
List<ServerProviderLocation> locations = [];
|
List<ServerProviderLocation> locations = [];
|
||||||
|
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
|
@ -730,15 +731,20 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
.toList();
|
.toList();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
return APIGenericResult(
|
||||||
|
data: [],
|
||||||
|
success: false,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
close(client);
|
close(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return locations;
|
return APIGenericResult(data: locations, success: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<ServerType>> getServerTypesByLocation({
|
Future<APIGenericResult<List<ServerType>>> getServerTypesByLocation({
|
||||||
required final ServerProviderLocation location,
|
required final ServerProviderLocation location,
|
||||||
}) async {
|
}) async {
|
||||||
final List<ServerType> types = [];
|
final List<ServerType> types = [];
|
||||||
|
@ -771,11 +777,16 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
return APIGenericResult(
|
||||||
|
data: [],
|
||||||
|
success: false,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
close(client);
|
close(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return types;
|
return APIGenericResult(data: types, success: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -707,7 +707,8 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<ServerProviderLocation>> getAvailableLocations() async {
|
Future<APIGenericResult<List<ServerProviderLocation>>>
|
||||||
|
getAvailableLocations() async {
|
||||||
List<ServerProviderLocation> locations = [];
|
List<ServerProviderLocation> locations = [];
|
||||||
|
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
|
@ -728,15 +729,20 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
.toList();
|
.toList();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
return APIGenericResult(
|
||||||
|
success: false,
|
||||||
|
data: [],
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
close(client);
|
close(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return locations;
|
return APIGenericResult(success: true, data: locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<ServerType>> getServerTypesByLocation({
|
Future<APIGenericResult<List<ServerType>>> getServerTypesByLocation({
|
||||||
required final ServerProviderLocation location,
|
required final ServerProviderLocation location,
|
||||||
}) async {
|
}) async {
|
||||||
final List<ServerType> types = [];
|
final List<ServerType> types = [];
|
||||||
|
@ -769,11 +775,16 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
return APIGenericResult(
|
||||||
|
data: [],
|
||||||
|
success: false,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
close(client);
|
close(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return types;
|
return APIGenericResult(data: types, success: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -22,8 +22,9 @@ class ProviderApiTokenValidation {
|
||||||
|
|
||||||
abstract class ServerProviderApi extends ApiMap {
|
abstract class ServerProviderApi extends ApiMap {
|
||||||
Future<List<ServerBasicInfo>> getServers();
|
Future<List<ServerBasicInfo>> getServers();
|
||||||
Future<List<ServerProviderLocation>> getAvailableLocations();
|
Future<APIGenericResult<List<ServerProviderLocation>>>
|
||||||
Future<List<ServerType>> getServerTypesByLocation({
|
getAvailableLocations();
|
||||||
|
Future<APIGenericResult<List<ServerType>>> getServerTypesByLocation({
|
||||||
required final ServerProviderLocation location,
|
required final ServerProviderLocation location,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,18 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiController.currentServerProviderApiFactory!
|
final APIGenericResult apiResult = await ApiController
|
||||||
|
.currentServerProviderApiFactory!
|
||||||
.getServerProvider()
|
.getServerProvider()
|
||||||
.getAvailableLocations();
|
.getAvailableLocations();
|
||||||
|
|
||||||
|
if (!apiResult.success) {
|
||||||
|
getIt<NavigationService>().showSnackBar(
|
||||||
|
'initializing.could_not_connect'.tr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ServerType>> fetchAvailableTypesByLocation(
|
Future<List<ServerType>> fetchAvailableTypesByLocation(
|
||||||
|
@ -135,9 +144,18 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiController.currentServerProviderApiFactory!
|
final APIGenericResult apiResult = await ApiController
|
||||||
|
.currentServerProviderApiFactory!
|
||||||
.getServerProvider()
|
.getServerProvider()
|
||||||
.getServerTypesByLocation(location: location);
|
.getServerTypesByLocation(location: location);
|
||||||
|
|
||||||
|
if (!apiResult.success) {
|
||||||
|
getIt<NavigationService>().showSnackBar(
|
||||||
|
'initializing.could_not_connect'.tr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setServerProviderKey(final String serverProviderKey) async {
|
void setServerProviderKey(final String serverProviderKey) async {
|
||||||
|
|
Loading…
Reference in a new issue