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.
55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import SessionUtilitiesKit
|
|
|
|
@objc
|
|
public class SSKEnvironment: NSObject {
|
|
@objc public let primaryStorage: OWSPrimaryStorage
|
|
public let tsAccountManager: TSAccountManager
|
|
public let reachabilityManager: SSKReachabilityManager
|
|
|
|
// Note: This property is configured after Environment is created.
|
|
public let notificationsManager: Atomic<NotificationsProtocol?> = Atomic(nil)
|
|
|
|
@objc public static var shared: SSKEnvironment!
|
|
|
|
public var isComplete: Bool {
|
|
(notificationsManager.wrappedValue != nil)
|
|
}
|
|
|
|
public var objectReadWriteConnection: YapDatabaseConnection
|
|
public var sessionStoreDBConnection: YapDatabaseConnection
|
|
public var migrationDBConnection: YapDatabaseConnection
|
|
public var analyticsDBConnection: YapDatabaseConnection
|
|
|
|
// MARK: - Initialization
|
|
|
|
@objc public init(
|
|
primaryStorage: OWSPrimaryStorage,
|
|
tsAccountManager: TSAccountManager,
|
|
reachabilityManager: SSKReachabilityManager
|
|
) {
|
|
self.primaryStorage = primaryStorage
|
|
self.tsAccountManager = tsAccountManager
|
|
self.reachabilityManager = reachabilityManager
|
|
|
|
self.objectReadWriteConnection = primaryStorage.newDatabaseConnection()
|
|
self.sessionStoreDBConnection = primaryStorage.newDatabaseConnection()
|
|
self.migrationDBConnection = primaryStorage.newDatabaseConnection()
|
|
self.analyticsDBConnection = primaryStorage.newDatabaseConnection()
|
|
|
|
super.init()
|
|
|
|
if SSKEnvironment.shared == nil {
|
|
SSKEnvironment.shared = self
|
|
}
|
|
}
|
|
|
|
// MARK: - Functions
|
|
|
|
public static func clearSharedForTests() {
|
|
shared = nil
|
|
}
|
|
}
|