Skip to content

Commit

Permalink
Remove more observers
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Jul 16, 2024
1 parent 0a5cd8c commit 3211195
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions deltachat-ios/Helper/NotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import UIKit

public class NotificationManager {

var anyIncomingMsgObserver: NSObjectProtocol?
var incomingMsgObserver: NSObjectProtocol?
var msgsNoticedObserver: NSObjectProtocol?

private let dcAccounts: DcAccounts
private var dcContext: DcContext

init(dcAccounts: DcAccounts) {
self.dcAccounts = dcAccounts
self.dcContext = dcAccounts.getSelected()
initObservers()

NotificationCenter.default.addObserver(self, selector: #selector(NotificationManager.handleIncomingMessageOnAnyAccount(_:)), name: .incomingMessageOnAnyAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(NotificationManager.handleIncomingMessage(_:)), name: .incomingMessage, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(NotificationManager.handleMessagesNoticed(_:)), name: .messagesNoticed, object: nil)
}

deinit {
Expand Down Expand Up @@ -73,29 +72,6 @@ public class NotificationManager {
}
}

private func initObservers() {
anyIncomingMsgObserver = NotificationCenter.default.addObserver(
forName: .incomingMessageOnAnyAccount,
object: nil, queue: OperationQueue.main
) { [weak self] notification in
self?.handleIncomingMessageOnAnyAccount(notification)
}

incomingMsgObserver = NotificationCenter.default.addObserver(
forName: .incomingMessage,
object: nil, queue: OperationQueue.main
) { [weak self] notification in
self?.handleIncomingMessage(notification)
}

msgsNoticedObserver = NotificationCenter.default.addObserver(
forName: .messagesNoticed,
object: nil, queue: OperationQueue.main
) { [weak self] notification in
self?.handleMessagesNoticed(notification)
}
}

// MARK: - Notifications

@objc private func handleMessagesNoticed(_ notification: Notification) {
Expand Down

0 comments on commit 3211195

Please sign in to comment.