mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Refactoring
This commit is contained in:
@@ -1170,32 +1170,28 @@ private final class NotificationExceptionsSearchContainerNode: SearchDisplayCont
|
||||
let updateNotificationsDisposable = self.updateNotificationsDisposable
|
||||
|
||||
let updateNotificationsView: (@escaping () -> Void) -> Void = { completion in
|
||||
let key: PostboxViewKey = .peerNotificationSettings(peerIds: Set(mode.peerIds))
|
||||
|
||||
updateNotificationsDisposable.set(context.account.postbox.combinedView(keys: [key]).start(next: { view in
|
||||
if let view = view.views[key] as? PeerNotificationSettingsView {
|
||||
let _ = (context.engine.data.get(
|
||||
EngineDataMap(view.notificationSettings.keys.map(TelegramEngine.EngineData.Item.Peer.Peer.init)),
|
||||
EngineDataMap(view.notificationSettings.keys.map(TelegramEngine.EngineData.Item.Peer.NotificationSettings.init))
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { peerMap, notificationSettingsMap in
|
||||
updateState { current in
|
||||
var current = current
|
||||
for (key, value) in view.notificationSettings {
|
||||
if let value = value as? TelegramPeerNotificationSettings,let local = current.mode.settings[key] {
|
||||
if !value.isEqual(to: local.settings), let maybePeer = peerMap[key], let peer = maybePeer, let settings = notificationSettingsMap[key], !settings._asNotificationSettings().isEqual(to: local.settings) {
|
||||
current = current.withUpdatedPeerSound(peer._asPeer(), settings.messageSound._asMessageSound()).withUpdatedPeerMuteInterval(peer._asPeer(), settings.muteState.timeInterval)
|
||||
}
|
||||
updateNotificationsDisposable.set(context.engine.data.subscribe(EngineDataMap(
|
||||
mode.peerIds.map(TelegramEngine.EngineData.Item.Peer.NotificationSettings.init)
|
||||
)).start(next: { notificationSettingsMap in
|
||||
let _ = (context.engine.data.get(
|
||||
EngineDataMap(notificationSettingsMap.keys.map(TelegramEngine.EngineData.Item.Peer.Peer.init)),
|
||||
EngineDataMap(notificationSettingsMap.keys.map(TelegramEngine.EngineData.Item.Peer.NotificationSettings.init))
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { peerMap, notificationSettingsMap in
|
||||
updateState { current in
|
||||
var current = current
|
||||
for (key, value) in notificationSettingsMap {
|
||||
if let local = current.mode.settings[key] {
|
||||
if !value._asNotificationSettings().isEqual(to: local.settings), let maybePeer = peerMap[key], let peer = maybePeer, let settings = notificationSettingsMap[key], !settings._asNotificationSettings().isEqual(to: local.settings) {
|
||||
current = current.withUpdatedPeerSound(peer._asPeer(), settings.messageSound._asMessageSound()).withUpdatedPeerMuteInterval(peer._asPeer(), settings.muteState.timeInterval)
|
||||
}
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
completion()
|
||||
})
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
|
||||
completion()
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user