update onboarding flow when the seed is already stored

pull/891/head
Ryan ZHAO 10 months ago
parent eec4c7f944
commit b2a7e142a3

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1103,7 +1103,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1103,7 +1103,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1108,7 +1108,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -1102,7 +1102,6 @@ The point that a message will disappear in a disappearing message update message
"qrNotRecoveryPassword" = "This QR code does not contain a Recovery Password";
"warning" = "Warning";
"quitButton" = "Quit";
"cancel" = "Cancel";
"onboardingBackLoadAccount" = "You cannot go back further. In order to stop loading your account, Session needs to quit.";
"onboardingBackAccountCreation" = "You cannot go back further. In order to cancel your account creation, Session needs to quit.";

@ -134,7 +134,8 @@ struct LandingScreen: View {
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: DisplayNameScreen(flow: .register))
viewController.setUpNavBarSessionIcon()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
viewController.setUpClearDataBackButton(flow: .register)
self.host.controller?.navigationController?.setViewControllers([viewController], animated: true)
}
private func restore() {

@ -60,7 +60,7 @@ struct LoadAccountScreen: View {
}
let (ed25519KeyPair, x25519KeyPair) = try! Identity.generate(from: seed)
Onboarding.Flow.link
Onboarding.Flow.recover
.preregister(
with: seed,
ed25519KeyPair: ed25519KeyPair,
@ -72,9 +72,10 @@ struct LoadAccountScreen: View {
}
// Otherwise continue on to request push notifications permissions
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: PNModeScreen(flow: .link))
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: PNModeScreen(flow: .recover))
viewController.setUpNavBarSessionIcon()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
viewController.setUpClearDataBackButton(flow: .recover)
self.host.controller?.navigationController?.setViewControllers([viewController], animated: true)
}
func continueWithhexEncodedSeed(onSuccess: (() -> ())?, onError: (() -> ())?) {

@ -175,6 +175,6 @@ struct CircularProgressView: View {
struct LoadingView_Previews: PreviewProvider {
static var previews: some View {
LoadingScreen(flow: .link, preview: true)
LoadingScreen(flow: .recover, preview: true)
}
}

@ -100,7 +100,7 @@ enum Onboarding {
}
enum Flow {
case register, recover, link
case register, recover
/// If the user returns to an earlier screen during Onboarding we might need to clear out a partially created
/// account (eg. returning from the PN setting screen to the seed entry screen when linking a device)
@ -151,7 +151,7 @@ enum Onboarding {
)
// No need to show the seed again if the user is restoring or linking
db[.hasViewedSeed] = (self == .recover || self == .link)
db[.hasViewedSeed] = (self == .recover)
// Create a contact for the current user and set their approval/trusted statuses so
// they don't get weird behaviours

@ -2,6 +2,7 @@
import SwiftUI
import SessionUIKit
import SessionUtilitiesKit
public class HostWrapper: ObservableObject {
public weak var controller: UIViewController?
@ -120,6 +121,107 @@ public class SessionHostingViewController<Content>: UIHostingController<Modified
navigationItem.titleView = logoImageView
}
internal func setUpClearDataBackButton(flow: Onboarding.Flow) {
if #available(iOS 16.0, *) {
navigationItem.backAction = UIAction() { [weak self] action in
switch flow {
case .register:
self?.clearDataForAccountCreation()
case .recover:
self?.clearDataForLoadAccount()
}
}
} else {
let action: Selector = {
switch flow {
case .register:
return #selector(clearDataForAccountCreation)
case .recover:
return #selector(clearDataForLoadAccount)
}
}()
let clearDataBackButton = UIBarButtonItem(
image: UIImage(
systemName: "chevron.backward",
withConfiguration: UIImage.SymbolConfiguration(textStyle: .headline, scale: .large)
),
style: .plain,
target: self,
action: action
)
clearDataBackButton.imageInsets = .init(top: 0, leading: -8, bottom: 0, trailing: 8)
clearDataBackButton.themeTintColor = .textPrimary
navigationItem.leftBarButtonItem = clearDataBackButton
}
}
@objc private func clearDataForAccountCreation() {
let modal: ConfirmationModal = ConfirmationModal(
targetView: self.view,
info: ConfirmationModal.Info(
title: "warning".localized(),
body: .text("onboardingBackAccountCreation".localized()),
confirmTitle: "quitButton".localized(),
confirmStyle: .danger,
cancelStyle: .textPrimary,
onConfirm: { [weak self] confirmationModal in
self?.deleteAllLocalData()
}
)
)
self.present(modal, animated: true)
}
@objc private func clearDataForLoadAccount() {
let modal: ConfirmationModal = ConfirmationModal(
targetView: self.view,
info: ConfirmationModal.Info(
title: "warning".localized(),
body: .text("onboardingBackLoadAccount".localized()),
confirmTitle: "quitButton".localized(),
confirmStyle: .danger,
cancelStyle: .textPrimary,
onConfirm: { [weak self] confirmationModal in
self?.deleteAllLocalData()
}
)
)
self.present(modal, animated: true)
}
private func deleteAllLocalData(using dependencies: Dependencies = Dependencies()) {
/// Stop and cancel all current jobs (don't want to inadvertantly have a job store data after it's table has already been cleared)
///
/// **Note:** This is file as long as this process kills the app, if it doesn't then we need an alternate mechanism to flag that
/// the `JobRunner` is allowed to start it's queues again
JobRunner.stopAndClearPendingJobs(using: dependencies)
// Clear the app badge and notifications
AppEnvironment.shared.notificationPresenter.clearAllNotifications()
UIApplication.shared.applicationIconBadgeNumber = 0
// Clear out the user defaults
UserDefaults.removeAll()
// Remove the cached key so it gets re-cached on next access
dependencies.caches.mutate(cache: .general) {
$0.encodedPublicKey = nil
$0.recentReactionTimestamps = []
}
// Stop any pollers
(UIApplication.shared.delegate as? AppDelegate)?.stopPollers()
// Call through to the SessionApp's "resetAppData" which will wipe out logs, database and
// profile storage
let wasUnlinked: Bool = UserDefaults.standard[.wasUnlinked]
SessionApp.resetAppData {
// Resetting the data clears the old user defaults. We need to restore the unlink default.
UserDefaults.standard[.wasUnlinked] = wasUnlinked
}
}
internal func setUpDismissingButton(on postion: NavigationItemPosition) {
let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close))
closeButton.themeTintColor = .textPrimary

Loading…
Cancel
Save