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/cubit/server_installation/server_installation_repository.dart';
import 'package:selfprivacy/logic/models/server_provider_location.dart'; import 'package:selfprivacy/logic/models/server_provider_location.dart';
import 'package:selfprivacy/logic/models/server_type.dart'; import 'package:selfprivacy/logic/models/server_type.dart';
import 'package:selfprivacy/ui/helpers/modals.dart';
export 'package:provider/provider.dart'; export 'package:provider/provider.dart';
@ -256,31 +255,11 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
); );
if (!result.success && result.data != null) { if (!result.success && result.data != null) {
CallbackDialogueBranching branching = result.data!; emit(
//while (!dialoguesResolved) { (state as ServerInstallationNotFinished).copyWith(
showPopUpAlert( installationDialoguePopUp: result.data,
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!;
},
); );
//}
} }
} }

View file

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

View file

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