feat: Move current installation dialogue error to installation state

This commit is contained in:
NaiJi 2023-06-02 19:04:23 -03:00
parent 040fc43e1f
commit 4da4ed6afd
3 changed files with 22 additions and 26 deletions

View file

@ -19,7 +19,6 @@ import 'package:selfprivacy/logic/models/server_basic_info.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_repository.dart';
import 'package:selfprivacy/logic/models/server_provider_location.dart';
import 'package:selfprivacy/logic/models/server_type.dart';
import 'package:selfprivacy/ui/helpers/modals.dart';
export 'package:provider/provider.dart';
@ -256,31 +255,11 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
);
if (!result.success && result.data != null) {
CallbackDialogueBranching branching = result.data!;
//while (!dialoguesResolved) {
showPopUpAlert(
alertTitle: branching.title,
description: branching.description,
actionButtonTitle: branching.choices[1].title,
actionButtonOnPressed: () async {
final branchingResult = await branching.choices[1].callback!();
if (branchingResult.data == null) {
return;
}
branching = branchingResult.data!;
},
cancelButtonTitle: branching.choices[0].title,
cancelButtonOnPressed: () async {
final branchingResult = await branching.choices[0].callback!();
if (branchingResult.data == null) {
return;
}
branching = branchingResult.data!;
},
emit(
(state as ServerInstallationNotFinished).copyWith(
installationDialoguePopUp: result.data,
),
);
//}
}
}

View file

@ -79,6 +79,7 @@ class ServerInstallationRepository {
if (box.get(BNames.hasFinalChecked, defaultValue: false)) {
StagingOptions.verifyCertificate = true;
return ServerInstallationFinished(
installationDialoguePopUp: null,
providerApiToken: providerApiToken!,
serverTypeIdentificator: serverTypeIdentificator ?? '',
dnsApiToken: dnsApiToken!,

View file

@ -12,6 +12,7 @@ abstract class ServerInstallationState extends Equatable {
required this.isServerStarted,
required this.isServerResetedFirstTime,
required this.isServerResetedSecondTime,
required this.installationDialoguePopUp,
});
@override
@ -25,6 +26,7 @@ abstract class ServerInstallationState extends Equatable {
serverDetails,
isServerStarted,
isServerResetedFirstTime,
installationDialoguePopUp
];
final String? providerApiToken;
@ -37,6 +39,7 @@ abstract class ServerInstallationState extends Equatable {
final bool isServerStarted;
final bool isServerResetedFirstTime;
final bool isServerResetedSecondTime;
final CallbackDialogueBranching? installationDialoguePopUp;
bool get isServerProviderApiKeyFilled => providerApiToken != null;
bool get isServerTypeFilled => serverTypeIdentificator != null;
@ -96,6 +99,7 @@ class TimerState extends ServerInstallationNotFinished {
isServerResetedFirstTime: dataState.isServerResetedFirstTime,
isServerResetedSecondTime: dataState.isServerResetedSecondTime,
dnsMatches: dataState.dnsMatches,
installationDialoguePopUp: dataState.installationDialoguePopUp,
);
final ServerInstallationNotFinished dataState;
@ -138,6 +142,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
super.serverDomain,
super.rootUser,
super.serverDetails,
super.installationDialoguePopUp,
});
final bool isLoading;
final Map<String, bool>? dnsMatches;
@ -155,6 +160,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
isServerResetedFirstTime,
isLoading,
dnsMatches,
installationDialoguePopUp,
];
ServerInstallationNotFinished copyWith({
@ -170,6 +176,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
final bool? isServerResetedSecondTime,
final bool? isLoading,
final Map<String, bool>? dnsMatches,
final CallbackDialogueBranching? installationDialoguePopUp,
}) =>
ServerInstallationNotFinished(
providerApiToken: providerApiToken ?? this.providerApiToken,
@ -187,6 +194,8 @@ class ServerInstallationNotFinished extends ServerInstallationState {
isServerResetedSecondTime ?? this.isServerResetedSecondTime,
isLoading: isLoading ?? this.isLoading,
dnsMatches: dnsMatches ?? this.dnsMatches,
installationDialoguePopUp:
installationDialoguePopUp ?? this.installationDialoguePopUp,
);
ServerInstallationFinished finish() => ServerInstallationFinished(
@ -200,6 +209,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
isServerStarted: isServerStarted,
isServerResetedFirstTime: isServerResetedFirstTime,
isServerResetedSecondTime: isServerResetedSecondTime,
installationDialoguePopUp: installationDialoguePopUp,
);
}
@ -218,6 +228,7 @@ class ServerInstallationEmpty extends ServerInstallationNotFinished {
isServerResetedSecondTime: false,
isLoading: false,
dnsMatches: null,
installationDialoguePopUp: null,
);
}
@ -233,6 +244,7 @@ class ServerInstallationFinished extends ServerInstallationState {
required super.isServerStarted,
required super.isServerResetedFirstTime,
required super.isServerResetedSecondTime,
required super.installationDialoguePopUp,
});
@override
@ -246,6 +258,7 @@ class ServerInstallationFinished extends ServerInstallationState {
serverDetails,
isServerStarted,
isServerResetedFirstTime,
installationDialoguePopUp,
];
}
@ -287,6 +300,7 @@ class ServerInstallationRecovery extends ServerInstallationState {
isServerStarted: true,
isServerResetedFirstTime: true,
isServerResetedSecondTime: true,
installationDialoguePopUp: null,
);
final RecoveryStep currentStep;
final ServerRecoveryCapabilities recoveryCapabilities;
@ -302,7 +316,8 @@ class ServerInstallationRecovery extends ServerInstallationState {
serverDetails,
isServerStarted,
isServerResetedFirstTime,
currentStep
currentStep,
installationDialoguePopUp
];
ServerInstallationRecovery copyWith({
@ -340,5 +355,6 @@ class ServerInstallationRecovery extends ServerInstallationState {
isServerStarted: true,
isServerResetedFirstTime: true,
isServerResetedSecondTime: true,
installationDialoguePopUp: null,
);
}