rename Environment to SessionEnvironment to avoid conflicts on SwiftUI @Environment
This commit is contained in:
parent
1adfc9cfbe
commit
0e376d0d8a
|
@ -814,7 +814,7 @@
|
|||
FDC438C927BB706500C60D73 /* SendDirectMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC438C827BB706500C60D73 /* SendDirectMessageRequest.swift */; };
|
||||
FDC438CB27BB7DB100C60D73 /* UpdateMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC438CA27BB7DB100C60D73 /* UpdateMessageRequest.swift */; };
|
||||
FDC438CD27BC641200C60D73 /* Set+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC438CC27BC641200C60D73 /* Set+Utilities.swift */; };
|
||||
FDC6D6F32860607300B04575 /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF0B7542807C4BB004C14C5 /* Environment.swift */; };
|
||||
FDC6D6F32860607300B04575 /* SessionEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF0B7542807C4BB004C14C5 /* SessionEnvironment.swift */; };
|
||||
FDC6D7602862B3F600B04575 /* Dependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC6D75F2862B3F600B04575 /* Dependencies.swift */; };
|
||||
FDCDB8DE2810F73B00352A0C /* Differentiable+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDCDB8DD2810F73B00352A0C /* Differentiable+Utilities.swift */; };
|
||||
FDCDB8E02811007F00352A0C /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDCDB8DF2811007F00352A0C /* HomeViewModel.swift */; };
|
||||
|
@ -1963,7 +1963,7 @@
|
|||
FDF0B74A28061F7A004C14C5 /* InteractionAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractionAttachment.swift; sourceTree = "<group>"; };
|
||||
FDF0B74E28079E5E004C14C5 /* SendReadReceiptsJob.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendReadReceiptsJob.swift; sourceTree = "<group>"; };
|
||||
FDF0B7502807BA56004C14C5 /* NotificationsProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsProtocol.swift; sourceTree = "<group>"; };
|
||||
FDF0B7542807C4BB004C14C5 /* Environment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = "<group>"; };
|
||||
FDF0B7542807C4BB004C14C5 /* SessionEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionEnvironment.swift; sourceTree = "<group>"; };
|
||||
FDF0B7572807F368004C14C5 /* MessageReceiverError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageReceiverError.swift; sourceTree = "<group>"; };
|
||||
FDF0B7592807F3A3004C14C5 /* MessageSenderError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageSenderError.swift; sourceTree = "<group>"; };
|
||||
FDF0B75B2807F41D004C14C5 /* MessageSender+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MessageSender+Convenience.swift"; sourceTree = "<group>"; };
|
||||
|
@ -3236,7 +3236,7 @@
|
|||
FD23CE232A675C440000B97C /* Crypto+SessionMessagingKit.swift */,
|
||||
FD859EF127BF6BA200510D0C /* Data+Utilities.swift */,
|
||||
C38EF309255B6DBE007E1867 /* DeviceSleepManager.swift */,
|
||||
FDF0B7542807C4BB004C14C5 /* Environment.swift */,
|
||||
FDF0B7542807C4BB004C14C5 /* SessionEnvironment.swift */,
|
||||
C3BBE0C62554F1570050F1E3 /* FixedWidthInteger+BigEndian.swift */,
|
||||
C3A71D0A2558989C0043A11F /* MessageWrapper.swift */,
|
||||
C38EF2F5255B6DBC007E1867 /* OWSAudioPlayer.h */,
|
||||
|
@ -5847,7 +5847,7 @@
|
|||
FD17D79927F40AB800122BE0 /* _003_YDBToGRDBMigration.swift in Sources */,
|
||||
FDF0B7512807BA56004C14C5 /* NotificationsProtocol.swift in Sources */,
|
||||
B8DE1FB426C22F2F0079C9CE /* WebRTCSession.swift in Sources */,
|
||||
FDC6D6F32860607300B04575 /* Environment.swift in Sources */,
|
||||
FDC6D6F32860607300B04575 /* SessionEnvironment.swift in Sources */,
|
||||
C3A3A171256E1D25004D228D /* SSKReachabilityManager.swift in Sources */,
|
||||
FD245C59285065FC00B966DD /* ControlMessage.swift in Sources */,
|
||||
B8DE1FB626C22FCB0079C9CE /* CallMessage.swift in Sources */,
|
||||
|
|
|
@ -417,7 +417,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
|
|||
private func tryToReconnect() {
|
||||
reconnectTimer?.invalidate()
|
||||
|
||||
guard Environment.shared?.reachabilityManager.isReachable == true else {
|
||||
guard SessionEnvironment.shared?.reachabilityManager.isReachable == true else {
|
||||
reconnectTimer = Timer.scheduledTimerOnMainThread(withTimeInterval: 5, repeats: false) { _ in
|
||||
self.tryToReconnect()
|
||||
}
|
||||
|
|
|
@ -2249,7 +2249,7 @@ extension ConversationVC:
|
|||
let url: URL = URL(fileURLWithPath: directory).appendingPathComponent(fileName)
|
||||
|
||||
// Set up audio session
|
||||
let isConfigured = (Environment.shared?.audioSession.startAudioActivity(recordVoiceMessageActivity) == true)
|
||||
let isConfigured = (SessionEnvironment.shared?.audioSession.startAudioActivity(recordVoiceMessageActivity) == true)
|
||||
guard isConfigured else {
|
||||
return cancelVoiceMessageRecording()
|
||||
}
|
||||
|
@ -2357,7 +2357,7 @@ extension ConversationVC:
|
|||
|
||||
func stopVoiceMessageRecording() {
|
||||
audioRecorder?.stop()
|
||||
Environment.shared?.audioSession.endAudioActivity(recordVoiceMessageActivity)
|
||||
SessionEnvironment.shared?.audioSession.endAudioActivity(recordVoiceMessageActivity)
|
||||
}
|
||||
|
||||
// MARK: - Data Extraction Notifications
|
||||
|
|
|
@ -49,7 +49,7 @@ class PhotoCapture: NSObject {
|
|||
func startAudioCapture() throws {
|
||||
assertIsOnSessionQueue()
|
||||
|
||||
guard Environment.shared?.audioSession.startAudioActivity(recordingAudioActivity) == true else {
|
||||
guard SessionEnvironment.shared?.audioSession.startAudioActivity(recordingAudioActivity) == true else {
|
||||
throw PhotoCaptureError.assertionError(description: "unable to capture audio activity")
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class PhotoCapture: NSObject {
|
|||
}
|
||||
session.removeInput(audioDeviceInput)
|
||||
self.audioDeviceInput = nil
|
||||
Environment.shared?.audioSession.endAudioActivity(recordingAudioActivity)
|
||||
SessionEnvironment.shared?.audioSession.endAudioActivity(recordingAudioActivity)
|
||||
}
|
||||
|
||||
func startCapture() -> AnyPublisher<Void, Error> {
|
||||
|
|
|
@ -87,7 +87,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
}
|
||||
)
|
||||
|
||||
if Environment.shared?.callManager.wrappedValue?.currentCall == nil {
|
||||
if SessionEnvironment.shared?.callManager.wrappedValue?.currentCall == nil {
|
||||
UserDefaults.sharedLokiProject?.set(false, forKey: "isCallOngoing")
|
||||
}
|
||||
|
||||
|
@ -382,8 +382,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
}
|
||||
|
||||
// May as well run these on the background thread
|
||||
Environment.shared?.audioSession.setup()
|
||||
Environment.shared?.reachabilityManager.setup()
|
||||
SessionEnvironment.shared?.audioSession.setup()
|
||||
SessionEnvironment.shared?.reachabilityManager.setup()
|
||||
}
|
||||
|
||||
private func showFailedStartupAlert(
|
||||
|
|
|
@ -46,10 +46,10 @@ public class AppEnvironment {
|
|||
|
||||
public func setup() {
|
||||
// Hang certain singletons on Environment too.
|
||||
Environment.shared?.callManager.mutate {
|
||||
SessionEnvironment.shared?.callManager.mutate {
|
||||
$0 = callManager
|
||||
}
|
||||
Environment.shared?.notificationsManager.mutate {
|
||||
SessionEnvironment.shared?.notificationsManager.mutate {
|
||||
$0 = notificationPresenter
|
||||
}
|
||||
setupLogFiles()
|
||||
|
|
|
@ -45,7 +45,7 @@ final class PathStatusView: UIView {
|
|||
// MARK: - Initialization
|
||||
|
||||
private let size: Size
|
||||
private let reachability: Reachability? = Environment.shared?.reachabilityManager.reachability
|
||||
private let reachability: Reachability? = SessionEnvironment.shared?.reachabilityManager.reachability
|
||||
|
||||
init(size: Size = .small) {
|
||||
self.size = size
|
||||
|
|
|
@ -253,7 +253,7 @@ private final class LineView: UIView {
|
|||
private var dotViewWidthConstraint: NSLayoutConstraint!
|
||||
private var dotViewHeightConstraint: NSLayoutConstraint!
|
||||
private var dotViewAnimationTimer: Timer!
|
||||
private let reachability: Reachability? = Environment.shared?.reachabilityManager.reachability
|
||||
private let reachability: Reachability? = SessionEnvironment.shared?.reachabilityManager.reachability
|
||||
|
||||
enum Location {
|
||||
case top, middle, bottom
|
||||
|
|
|
@ -102,7 +102,7 @@ class ScreenLockUI {
|
|||
return .none;
|
||||
}
|
||||
|
||||
if Environment.shared?.isRequestingPermission == true {
|
||||
if SessionEnvironment.shared?.isRequestingPermission == true {
|
||||
return .none;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,10 +105,10 @@ public enum Permissions {
|
|||
// the picker view then will dismiss, too. The selection process cannot be finished
|
||||
// this way. So we add a flag (isRequestingPermission) to prevent the ScreenLockUI
|
||||
// from showing when we request the photo library permission.
|
||||
Environment.shared?.isRequestingPermission = true
|
||||
SessionEnvironment.shared?.isRequestingPermission = true
|
||||
|
||||
PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in
|
||||
Environment.shared?.isRequestingPermission = false
|
||||
SessionEnvironment.shared?.isRequestingPermission = false
|
||||
if [ PHAuthorizationStatus.authorized, PHAuthorizationStatus.limited ].contains(status) {
|
||||
onAuthorized()
|
||||
}
|
||||
|
|
|
@ -516,7 +516,7 @@ public extension Interaction {
|
|||
)
|
||||
|
||||
// Clear out any notifications for the interactions we mark as read
|
||||
Environment.shared?.notificationsManager.wrappedValue?.cancelNotifications(
|
||||
SessionEnvironment.shared?.notificationsManager.wrappedValue?.cancelNotifications(
|
||||
identifiers: interactionInfo
|
||||
.map { interactionInfo in
|
||||
Interaction.notificationIdentifier(
|
||||
|
|
|
@ -69,7 +69,7 @@ extension MessageReceiver {
|
|||
.fetchOrCreate(db, id: sender, variant: .contact, shouldBeVisible: nil)
|
||||
|
||||
if !interaction.wasRead {
|
||||
Environment.shared?.notificationsManager.wrappedValue?
|
||||
SessionEnvironment.shared?.notificationsManager.wrappedValue?
|
||||
.notifyUser(
|
||||
db,
|
||||
forIncomingCall: interaction,
|
||||
|
@ -87,7 +87,7 @@ extension MessageReceiver {
|
|||
.fetchOrCreate(db, id: sender, variant: .contact, shouldBeVisible: nil)
|
||||
|
||||
if !interaction.wasRead {
|
||||
Environment.shared?.notificationsManager.wrappedValue?
|
||||
SessionEnvironment.shared?.notificationsManager.wrappedValue?
|
||||
.notifyUser(
|
||||
db,
|
||||
forIncomingCall: interaction,
|
||||
|
@ -107,7 +107,7 @@ extension MessageReceiver {
|
|||
}
|
||||
|
||||
// Ensure we have a call manager before continuing
|
||||
guard let callManager: CallManagerProtocol = Environment.shared?.callManager.wrappedValue else { return }
|
||||
guard let callManager: CallManagerProtocol = SessionEnvironment.shared?.callManager.wrappedValue else { return }
|
||||
|
||||
// Ignore pre offer message after the same call instance has been generated
|
||||
if let currentCall: CurrentCallProtocol = callManager.currentCall, currentCall.uuid == message.uuid {
|
||||
|
@ -135,7 +135,7 @@ extension MessageReceiver {
|
|||
|
||||
// Ensure we have a call manager before continuing
|
||||
guard
|
||||
let callManager: CallManagerProtocol = Environment.shared?.callManager.wrappedValue,
|
||||
let callManager: CallManagerProtocol = SessionEnvironment.shared?.callManager.wrappedValue,
|
||||
let currentCall: CurrentCallProtocol = callManager.currentCall,
|
||||
currentCall.uuid == message.uuid,
|
||||
let sdp: String = message.sdps.first
|
||||
|
@ -151,7 +151,7 @@ extension MessageReceiver {
|
|||
guard
|
||||
let currentWebRTCSession: WebRTCSession = WebRTCSession.current,
|
||||
currentWebRTCSession.uuid == message.uuid,
|
||||
let callManager: CallManagerProtocol = Environment.shared?.callManager.wrappedValue,
|
||||
let callManager: CallManagerProtocol = SessionEnvironment.shared?.callManager.wrappedValue,
|
||||
var currentCall: CurrentCallProtocol = callManager.currentCall,
|
||||
currentCall.uuid == message.uuid,
|
||||
let sender: String = message.sender
|
||||
|
@ -177,7 +177,7 @@ extension MessageReceiver {
|
|||
|
||||
guard
|
||||
WebRTCSession.current?.uuid == message.uuid,
|
||||
let callManager: CallManagerProtocol = Environment.shared?.callManager.wrappedValue,
|
||||
let callManager: CallManagerProtocol = SessionEnvironment.shared?.callManager.wrappedValue,
|
||||
let currentCall: CurrentCallProtocol = callManager.currentCall,
|
||||
currentCall.uuid == message.uuid,
|
||||
let sender: String = message.sender
|
||||
|
|
|
@ -337,7 +337,7 @@ extension MessageReceiver {
|
|||
guard variant == .standardIncoming && !interaction.wasRead else { return interactionId }
|
||||
|
||||
// Use the same identifier for notifications when in backgroud polling to prevent spam
|
||||
Environment.shared?.notificationsManager.wrappedValue?
|
||||
SessionEnvironment.shared?.notificationsManager.wrappedValue?
|
||||
.notifyUser(
|
||||
db,
|
||||
for: interaction,
|
||||
|
@ -408,7 +408,7 @@ extension MessageReceiver {
|
|||
// Don't notify if the reaction was added before the lastest read timestamp for
|
||||
// the conversation
|
||||
if sender != currentUserPublicKey && !timestampAlreadyRead {
|
||||
Environment.shared?.notificationsManager.wrappedValue?
|
||||
SessionEnvironment.shared?.notificationsManager.wrappedValue?
|
||||
.notifyUser(
|
||||
db,
|
||||
forReaction: reaction,
|
||||
|
|
|
@ -18,7 +18,7 @@ public class AudioActivity: NSObject {
|
|||
}
|
||||
|
||||
deinit {
|
||||
Environment.shared?.audioSession.ensureAudioSessionActivationStateAfterDelay()
|
||||
SessionEnvironment.shared?.audioSession.ensureAudioSessionActivationStateAfterDelay()
|
||||
}
|
||||
|
||||
// MARK:
|
||||
|
@ -84,9 +84,9 @@ public class OWSAudioSession: NSObject {
|
|||
|
||||
func ensureAudioCategory() throws {
|
||||
if aggregateBehaviors.contains(.audioMessagePlayback) {
|
||||
Environment.shared?.proximityMonitoringManager.add(lifetime: self)
|
||||
SessionEnvironment.shared?.proximityMonitoringManager.add(lifetime: self)
|
||||
} else {
|
||||
Environment.shared?.proximityMonitoringManager.remove(lifetime: self)
|
||||
SessionEnvironment.shared?.proximityMonitoringManager.remove(lifetime: self)
|
||||
}
|
||||
|
||||
if aggregateBehaviors.contains(.call) {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
import Foundation
|
||||
import SessionUtilitiesKit
|
||||
|
||||
public class Environment {
|
||||
public static var shared: Environment?
|
||||
public class SessionEnvironment {
|
||||
public static var shared: SessionEnvironment?
|
||||
|
||||
public let reachabilityManager: SSKReachabilityManager
|
||||
|
||||
|
@ -37,8 +37,8 @@ public class Environment {
|
|||
self.windowManager = windowManager
|
||||
self.isRequestingPermission = false
|
||||
|
||||
if Environment.shared == nil {
|
||||
Environment.shared = self
|
||||
if SessionEnvironment.shared == nil {
|
||||
SessionEnvironment.shared = self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@ public class Environment {
|
|||
public class SMKEnvironment: NSObject {
|
||||
@objc public static let shared: SMKEnvironment = SMKEnvironment()
|
||||
|
||||
@objc public var audioSession: OWSAudioSession? { Environment.shared?.audioSession }
|
||||
@objc public var windowManager: OWSWindowManager? { Environment.shared?.windowManager }
|
||||
@objc public var audioSession: OWSAudioSession? { SessionEnvironment.shared?.audioSession }
|
||||
@objc public var windowManager: OWSWindowManager? { SessionEnvironment.shared?.windowManager }
|
||||
|
||||
@objc public var isRequestingPermission: Bool { (Environment.shared?.isRequestingPermission == true) }
|
||||
@objc public var isRequestingPermission: Bool { (SessionEnvironment.shared?.isRequestingPermission == true) }
|
||||
}
|
|
@ -154,7 +154,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|||
|
||||
// Notify the user if the call message wasn't already read
|
||||
if !interaction.wasRead {
|
||||
Environment.shared?.notificationsManager.wrappedValue?
|
||||
SessionEnvironment.shared?.notificationsManager.wrappedValue?
|
||||
.notifyUser(
|
||||
db,
|
||||
forIncomingCall: interaction,
|
||||
|
@ -230,7 +230,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|||
|
||||
AppSetup.setupEnvironment(
|
||||
appSpecificBlock: {
|
||||
Environment.shared?.notificationsManager.mutate {
|
||||
SessionEnvironment.shared?.notificationsManager.mutate {
|
||||
$0 = NSENotificationPresenter()
|
||||
}
|
||||
},
|
||||
|
|
|
@ -54,7 +54,7 @@ final class ShareNavController: UINavigationController, ShareViewDelegate {
|
|||
|
||||
AppSetup.setupEnvironment(
|
||||
appSpecificBlock: {
|
||||
Environment.shared?.notificationsManager.mutate {
|
||||
SessionEnvironment.shared?.notificationsManager.mutate {
|
||||
$0 = NoopNotificationsManager()
|
||||
}
|
||||
},
|
||||
|
|
|
@ -31,12 +31,12 @@ public class OWSVideoPlayer {
|
|||
@objc
|
||||
public func pause() {
|
||||
avPlayer.pause()
|
||||
Environment.shared?.audioSession.endAudioActivity(self.audioActivity)
|
||||
SessionEnvironment.shared?.audioSession.endAudioActivity(self.audioActivity)
|
||||
}
|
||||
|
||||
@objc
|
||||
public func play() {
|
||||
let success = (Environment.shared?.audioSession.startAudioActivity(self.audioActivity) == true)
|
||||
let success = (SessionEnvironment.shared?.audioSession.startAudioActivity(self.audioActivity) == true)
|
||||
assert(success)
|
||||
|
||||
guard let item = avPlayer.currentItem else {
|
||||
|
@ -56,7 +56,7 @@ public class OWSVideoPlayer {
|
|||
public func stop() {
|
||||
avPlayer.pause()
|
||||
avPlayer.seek(to: CMTime.zero, toleranceBefore: .zero, toleranceAfter: .zero)
|
||||
Environment.shared?.audioSession.endAudioActivity(self.audioActivity)
|
||||
SessionEnvironment.shared?.audioSession.endAudioActivity(self.audioActivity)
|
||||
}
|
||||
|
||||
@objc(seekToTime:)
|
||||
|
@ -69,6 +69,6 @@ public class OWSVideoPlayer {
|
|||
@objc
|
||||
private func playerItemDidPlayToCompletion(_ notification: Notification) {
|
||||
self.delegate?.videoPlayerDidPlayToCompletion(self)
|
||||
Environment.shared?.audioSession.endAudioActivity(self.audioActivity)
|
||||
SessionEnvironment.shared?.audioSession.endAudioActivity(self.audioActivity)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public enum AppSetup {
|
|||
)
|
||||
assert(success)
|
||||
|
||||
Environment.shared = Environment(
|
||||
SessionEnvironment.shared = SessionEnvironment(
|
||||
reachabilityManager: SSKReachabilityManagerImpl(),
|
||||
audioSession: OWSAudioSession(),
|
||||
proximityMonitoringManager: OWSProximityMonitoringManagerImpl(),
|
||||
|
|
Loading…
Reference in New Issue