mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-17 22:29:15 +00:00
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:
commit
7db7cd79b0
|
@ -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 {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue