diff --git a/CHANGES.rst b/CHANGES.rst index 2dd3d4f43f..1933d25107 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,7 @@ Changes to be released in next version * Directory List (pop-up one): Fix duplicate rooms being shown (#4537). * Use different title for scan button for self verification (#4525). * it's easy for the back button to trigger a leftpanel reveal (#4438). + * Show / hide reset button in secrets recovery screen (#4546). ⚠️ API Changes * diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index 0d5ae6dae0..19c2ec7331 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -321,6 +321,9 @@ final class BuildSettings: NSObject { static let authScreenShowForgotPassword = true static let authScreenShowCustomServerOptions = true - // Mark: - Unified Search + // MARK: - Unified Search static let unifiedSearchScreenShowPublicDirectory = true + + // MARK: - Secrets Recovery + static let secretsRecoveryAllowReset = true } diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 533702c2ba..5a6817acaf 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -80,6 +80,7 @@ final class RiotSettings: NSObject { static let roomMemberScreenShowIgnore = "roomMemberScreenShowIgnore" static let unifiedSearchScreenShowPublicDirectory = "unifiedSearchScreenShowPublicDirectory" static let hideSpaceBetaAnnounce = "hideSpaceBetaAnnounce" + static let secretsRecoveryAllowReset = "secretsRecoveryAllowReset" } static let shared = RiotSettings() @@ -695,7 +696,7 @@ final class RiotSettings: NSObject { } } - // Mark: - Unified Search + // MARK: - Unified Search var unifiedSearchScreenShowPublicDirectory: Bool { get { @@ -708,6 +709,19 @@ final class RiotSettings: NSObject { } } + // MARK: - Secrets Recovery + + var secretsRecoveryAllowReset: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.secretsRecoveryAllowReset) != nil else { + return BuildSettings.secretsRecoveryAllowReset + } + return defaults.bool(forKey: UserDefaultsKeys.secretsRecoveryAllowReset) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.secretsRecoveryAllowReset) + } + } + // MARK: - Beta var hideSpaceBetaAnnounce: Bool { diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift index a0cc96d35c..911f083023 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift @@ -123,6 +123,8 @@ final class SecretsRecoveryWithKeyViewController: UIViewController { self.updateRecoverButton() self.resetSecretsButton.vc_enableMultiLinesTitle() + + self.resetSecretsButton.isHidden = !RiotSettings.shared.secretsRecoveryAllowReset } private func update(theme: Theme) { diff --git a/Riot/Modules/Secrets/Recover/RecoverWithPassphrase/SecretsRecoveryWithPassphraseViewController.swift b/Riot/Modules/Secrets/Recover/RecoverWithPassphrase/SecretsRecoveryWithPassphraseViewController.swift index c1fcaaec4b..5c64fd51b8 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithPassphrase/SecretsRecoveryWithPassphraseViewController.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithPassphrase/SecretsRecoveryWithPassphraseViewController.swift @@ -125,6 +125,8 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController { self.updateRecoverButton() self.resetSecretsButton.vc_enableMultiLinesTitle() + + self.resetSecretsButton.isHidden = !RiotSettings.shared.secretsRecoveryAllowReset } private func update(theme: Theme) {