mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Support refreshDueToExternalTransaction in more views
This commit is contained in:
@@ -36,6 +36,43 @@ final class MutablePeerNotificationSettingsView: MutablePostboxView {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func refreshDueToExternalTransaction(postbox: PostboxImpl) -> Bool {
|
||||
var notificationSettings: [PeerId: PeerNotificationSettings] = [:]
|
||||
for peerId in self.peerIds {
|
||||
var notificationPeerId = peerId
|
||||
if let peer = postbox.peerTable.get(peerId), let associatedPeerId = peer.associatedPeerId {
|
||||
notificationPeerId = associatedPeerId
|
||||
}
|
||||
if let settings = postbox.peerNotificationSettingsTable.getEffective(notificationPeerId) {
|
||||
notificationSettings[peerId] = settings
|
||||
}
|
||||
}
|
||||
|
||||
var updated = false
|
||||
if self.notificationSettings.count != notificationSettings.count {
|
||||
updated = true
|
||||
} else {
|
||||
for (key, value) in self.notificationSettings {
|
||||
if let other = notificationSettings[key] {
|
||||
if !other.isEqual(to: value) {
|
||||
updated = true
|
||||
break
|
||||
}
|
||||
} else {
|
||||
updated = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if updated {
|
||||
self.notificationSettings = notificationSettings
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func immutableView() -> PostboxView {
|
||||
return PeerNotificationSettingsView(self)
|
||||
|
||||
Reference in New Issue
Block a user