mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import GRDB
|
|
import SessionUtilitiesKit
|
|
|
|
public extension Identity {
|
|
/// The user actually exists very early on during the onboarding process but there are also a few cases
|
|
/// where we want to know that the user is in a valid state (ie. has completed the proper onboarding
|
|
/// process), this value indicates that state
|
|
///
|
|
/// One case which can happen is if the app crashed during onboarding the user can be left in an invalid
|
|
/// state (ie. with no display name) - the user would be asked to enter one on a subsequent launch to
|
|
/// resolve the invalid state
|
|
static func userCompletedRequiredOnboarding(
|
|
_ db: Database? = nil,
|
|
using dependencies: Dependencies
|
|
) -> Bool {
|
|
guard Identity.userExists(db, using: dependencies) else { return false }
|
|
|
|
switch db {
|
|
case .none: return !Profile.fetchOrCreateCurrentUser(using: dependencies).name.isEmpty
|
|
case .some(let db): return !Profile.fetchOrCreateCurrentUser(db, using: dependencies).name.isEmpty
|
|
}
|
|
}
|
|
}
|