From eba82d532e1f35b5685c30b93403a9febbb89367 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 16 Dec 2020 14:41:00 +1100 Subject: [PATCH] Add persistent upgrade Session ID button for V1 users --- Session/View Controllers/SettingsVC.swift | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Session/View Controllers/SettingsVC.swift b/Session/View Controllers/SettingsVC.swift index 615645038..cbfe660df 100644 --- a/Session/View Controllers/SettingsVC.swift +++ b/Session/View Controllers/SettingsVC.swift @@ -170,19 +170,28 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { button.set(.height, to: Values.settingButtonHeight) return button } - return [ + var result = [ getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_privacy_button_title", comment: ""), color: Colors.text, action: #selector(showPrivacySettings)), getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_notifications_button_title", comment: ""), color: Colors.text, action: #selector(showNotificationSettings)), getSeparator(), getSettingButton(withTitle: "Invite", color: Colors.text, action: #selector(sendInvitation)), - getSeparator(), + getSeparator() + ] + if !KeyPairUtilities.hasV2KeyPair() { + result += [ + getSettingButton(withTitle: "Upgrade Session ID", color: Colors.text, action: #selector(upgradeSessionID)), + getSeparator() + ] + } + result += [ getSettingButton(withTitle: NSLocalizedString("vc_settings_recovery_phrase_button_title", comment: ""), color: Colors.text, action: #selector(showSeed)), getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_clear_all_data_button_title", comment: ""), color: Colors.destructive, action: #selector(clearAllData)), getSeparator() ] + return result } // MARK: General @@ -389,6 +398,16 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { navigationController!.present(shareVC, animated: true, completion: nil) } + @objc private func upgradeSessionID() { + let message = "You’re upgrading to a new Session ID. This will give you improved privacy and security, but it will clear ALL app data. Contacts and conversations will be lost. Proceed?" + let alert = UIAlertController(title: "Upgrade Session ID?", message: message, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "Yes", style: .destructive) { _ in + Storage.reset() + }) + alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil)) + present(alert, animated: true, completion: nil) + } + @objc private func showSeed() { let seedModal = SeedModal() seedModal.modalPresentationStyle = .overFullScreen