session-ios/SessionMessagingKit/Utilities/Identity+Utilities.swift

20 lines
852 B
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) -> Bool {
Identity.userExists(db) &&
!Profile.fetchOrCreateCurrentUser(db).name.isEmpty
}
}