From f938a04c5e2b6be7a3c2742d8d18edff85e24721 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Sun, 8 Sep 2024 21:14:25 +0400 Subject: [PATCH] fix(recovery): Fix installation recovery current step resolving - Refactor the nested if-pyramid - Replace the DnsProviderType check with a simple check for a token string, since we receive DnsProviderType from the server and the user has no actions in it - Make sure the server selection prompt isn't skipped before asking for a DNS token - Resolve: #395 --- .../server_installation_repository.dart | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/logic/cubit/server_installation/server_installation_repository.dart b/lib/logic/cubit/server_installation/server_installation_repository.dart index ec99e636..dd9bde1f 100644 --- a/lib/logic/cubit/server_installation/server_installation_repository.dart +++ b/lib/logic/cubit/server_installation/server_installation_repository.dart @@ -156,19 +156,22 @@ class ServerInstallationRepository { final ServerDomain serverDomain, final ServerHostingDetails? serverDetails, ) { - if (serverDetails != null) { - if (serverProviderToken != null) { - if (serverDetails.provider != ServerProviderType.unknown) { - if (serverDomain.provider != DnsProviderType.unknown) { - return RecoveryStep.backblazeToken; - } - return RecoveryStep.dnsProviderToken; - } - return RecoveryStep.serverSelection; - } + if (serverDetails == null) { + return RecoveryStep.selecting; + } + + if (serverProviderToken == null) { return RecoveryStep.serverProviderToken; } - return RecoveryStep.selecting; + + /// We don't write anything to the database after .serverSelection + /// step, therefore we have to re-ask it again before prompting for + /// DNS token, if it wasn't provided yet. + if (dnsProviderToken == null) { + return RecoveryStep.serverSelection; + } + + return RecoveryStep.backblazeToken; } void clearAppConfig() {