fix: Replace hard reset from server provider with direct server reboot

pull/269/head
NaiJi ✨ 2023-08-02 18:08:23 -03:00
parent 11e745f822
commit ffe923ef13
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$RunSystemRebuild();
if (response.hasException) {
print(response.exception.toString());
}
if (response.parsedData!.runSystemRebuild.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

@ -254,12 +254,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;