mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
move NotificationsManager behind NotificationsAdapter
This commit is contained in:
parent
ac3bbe26ba
commit
11afc967d2
|
@ -7,7 +7,6 @@
|
|||
#import "DebugLogger.h"
|
||||
#import "HomeViewController.h"
|
||||
#import "MainAppContext.h"
|
||||
#import "NotificationsManager.h"
|
||||
#import "OWS2FASettingsViewController.h"
|
||||
#import "OWSBackup.h"
|
||||
#import "OWSOrphanDataCleaner.h"
|
||||
|
|
|
@ -4,24 +4,21 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
@objc
|
||||
public protocol NotificationsAdaptee: NotificationsProtocol, OWSCallNotificationsAdaptee { }
|
||||
|
||||
extension NotificationsManager: NotificationsAdaptee { }
|
||||
|
||||
/**
|
||||
* Present call related notifications to the user.
|
||||
*/
|
||||
@objc(OWSNotificationsAdapter)
|
||||
public class NotificationsAdapter: NSObject {
|
||||
|
||||
var adaptee: OWSCallNotificationsAdaptee {
|
||||
// TODO: We may eventually want to use UserNotificationsAdaptee instead.
|
||||
//
|
||||
// We can't mix UILocalNotification (NotificationManager) with the UNNotifications
|
||||
// Because registering message categories in one, clobbers the registered categories from the other
|
||||
// We have to first port *all* the existing UINotification categories to UNNotifications
|
||||
// which is a good thing to do, but in trying to limit the scope of changes that's been
|
||||
// left out for now.
|
||||
return AppEnvironment.shared.notificationsManager
|
||||
}
|
||||
public class NotificationsAdapter: NSObject, NotificationsProtocol {
|
||||
private let adaptee: NotificationsAdaptee
|
||||
|
||||
@objc public override init() {
|
||||
self.adaptee = NotificationsManager()
|
||||
|
||||
super.init()
|
||||
|
||||
SwiftSingletons.register(self)
|
||||
|
@ -45,4 +42,20 @@ public class NotificationsAdapter: NSObject {
|
|||
adaptee.presentMissedCallBecauseOfNewIdentity(call: call, callerName: callerName)
|
||||
}
|
||||
|
||||
// MJK TODO DI contactsManager
|
||||
public func notifyUser(for incomingMessage: TSIncomingMessage, in thread: TSThread, contactsManager: ContactsManagerProtocol, transaction: YapDatabaseReadTransaction) {
|
||||
adaptee.notifyUser(for: incomingMessage, in: thread, contactsManager: contactsManager, transaction: transaction)
|
||||
}
|
||||
|
||||
public func notifyUser(for error: TSErrorMessage, thread: TSThread, transaction: YapDatabaseReadWriteTransaction) {
|
||||
adaptee.notifyUser(for: error, thread: thread, transaction: transaction)
|
||||
}
|
||||
|
||||
public func notifyUser(forThreadlessErrorMessage error: TSErrorMessage, transaction: YapDatabaseReadWriteTransaction) {
|
||||
adaptee.notifyUser(forThreadlessErrorMessage: error, transaction: transaction)
|
||||
}
|
||||
|
||||
public func clearAllNotifications() {
|
||||
adaptee.clearAllNotifications()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,8 @@ class DebugUINotifications: DebugUIPage {
|
|||
|
||||
// MARK: Dependencies
|
||||
|
||||
var notificationsManager: NotificationsManager {
|
||||
return AppEnvironment.shared.notificationsManager
|
||||
}
|
||||
var notificationsAdapter: NotificationsAdapter {
|
||||
return AppEnvironment.shared.NotificationsAdapter
|
||||
return AppEnvironment.shared.notificationsAdapter
|
||||
}
|
||||
var messageSender: MessageSender {
|
||||
return SSKEnvironment.shared.messageSender
|
||||
|
@ -60,7 +57,7 @@ class DebugUINotifications: DebugUIPage {
|
|||
return
|
||||
}
|
||||
Logger.info("notifying user of incoming message")
|
||||
strongSelf.notificationsManager.notifyUser(for: incomingMessage, in: thread, contactsManager: strongSelf.contactsManager, transaction: transaction)
|
||||
strongSelf.notificationsAdapter.notifyUser(for: incomingMessage, in: thread, contactsManager: strongSelf.contactsManager, transaction: transaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ private class SignalCallData: NSObject {
|
|||
}
|
||||
|
||||
private var notificationsAdapter: NotificationsAdapter {
|
||||
return AppEnvironment.shared.NotificationsAdapter
|
||||
return AppEnvironment.shared.notificationsAdapter
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
|
|
@ -37,14 +37,11 @@ import SignalMessaging
|
|||
@objc
|
||||
public var messageFetcherJob: MessageFetcherJob
|
||||
|
||||
@objc
|
||||
public var notificationsManager: NotificationsManager
|
||||
|
||||
@objc
|
||||
public var accountManager: AccountManager
|
||||
|
||||
@objc
|
||||
public var NotificationsAdapter: NotificationsAdapter
|
||||
public var notificationsAdapter: NotificationsAdapter
|
||||
|
||||
@objc
|
||||
public var pushRegistrationManager: PushRegistrationManager
|
||||
|
@ -66,7 +63,6 @@ import SignalMessaging
|
|||
self.callService = CallService()
|
||||
self.outboundCallInitiator = OutboundCallInitiator()
|
||||
self.messageFetcherJob = MessageFetcherJob()
|
||||
self.notificationsManager = NotificationsManager()
|
||||
self.accountManager = AccountManager()
|
||||
self.notificationsAdapter = NotificationsAdapter()
|
||||
self.pushRegistrationManager = PushRegistrationManager()
|
||||
|
@ -85,7 +81,7 @@ import SignalMessaging
|
|||
callService.createCallUIAdapter()
|
||||
|
||||
// Hang certain singletons on SSKEnvironment too.
|
||||
SSKEnvironment.shared.notificationsManager = notificationsManager
|
||||
SSKEnvironment.shared.notificationsManager = notificationsAdapter
|
||||
SSKEnvironment.shared.callMessageHandler = callMessageHandler
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ConversationViewController.h"
|
||||
|
@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@class CallService;
|
||||
@class CallUIAdapter;
|
||||
@class HomeViewController;
|
||||
@class NotificationsManager;
|
||||
@class OWSMessageFetcherJob;
|
||||
@class OWSNavigationController;
|
||||
@class OWSWebRTCCallMessageHandler;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PushManager.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "NotificationsManager.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "SignalApp.h"
|
||||
#import "ThreadUtil.h"
|
||||
|
|
Loading…
Reference in a new issue