Merge pull request 'fix: Replace hard reset from server provider with direct server reboot' (#269) from soft-reset into master

Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/269
Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
Inex Code 2023-08-14 05:34:30 +03:00
commit 7db7cd79b0
3 changed files with 18 additions and 10 deletions

View file

@ -20,15 +20,23 @@ mixin ServerActionsApi on GraphQLApiMap {
return result;
}
Future<bool> reboot() async {
Future<GenericResult<DateTime?>> reboot() async {
DateTime? time;
try {
final GraphQLClient client = await getClient();
return await _commonBoolRequest(
() async => client.mutate$RebootSystem(),
);
final response = await client.mutate$RebootSystem();
if (response.hasException) {
print(response.exception.toString());
}
if (response.parsedData!.rebootSystem.success) {
time = DateTime.now();
}
} catch (e) {
return false;
print(e);
return GenericResult(data: time, success: false);
}
return GenericResult(data: time, success: true);
}
Future<bool> pullConfigurationUpdate() async {

View file

@ -54,8 +54,8 @@ class JobsCubit extends Cubit<JobsState> {
Future<void> rebootServer() async {
emit(JobsStateLoading());
final bool isSuccessful = await api.reboot();
if (isSuccessful) {
final rebootResult = await api.reboot();
if (rebootResult.success && rebootResult.data != null) {
getIt<NavigationService>().showSnackBar('jobs.reboot_success'.tr());
} else {
getIt<NavigationService>().showSnackBar('jobs.reboot_failed'.tr());

View file

@ -260,12 +260,12 @@ class ServerInstallationRepository {
Future<ServerHostingDetails> restart() async {
final server = getIt<ApiConfigModel>().serverDetails!;
final result = await ProvidersController.currentServerProvider!.restart(
server.id,
);
final result = await ServerApi().reboot();
if (result.success && result.data != null) {
server.copyWith(startTime: result.data);
} else {
getIt<NavigationService>().showSnackBar('jobs.reboot_failed'.tr());
}
return server;