mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Temp
This commit is contained in:
@@ -60,7 +60,7 @@ public struct GlobalNotificationSettingsSet: PostboxCoding, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct GlobalNotificationSettings: PreferencesEntry, Equatable {
|
||||
public struct GlobalNotificationSettings: PreferencesEntry, Equatable, PostboxGlobalNotificationSettings {
|
||||
public var toBeSynchronized: GlobalNotificationSettingsSet?
|
||||
public var remote: GlobalNotificationSettingsSet
|
||||
|
||||
@@ -74,6 +74,44 @@ public struct GlobalNotificationSettings: PreferencesEntry, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public func defaultIncludePeer(peer: Peer) -> Bool {
|
||||
let settings = self.effective
|
||||
if peer is TelegramUser || peer is TelegramSecretChat {
|
||||
return settings.privateChats.enabled
|
||||
} else if peer is TelegramGroup {
|
||||
return settings.groupChats.enabled
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
switch channel.info {
|
||||
case .group:
|
||||
return settings.groupChats.enabled
|
||||
case .broadcast:
|
||||
return settings.channels.enabled
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public func isEqualInDefaultPeerInclusion(other: PostboxGlobalNotificationSettings) -> Bool {
|
||||
guard let other = other as? GlobalNotificationSettings else {
|
||||
return false
|
||||
}
|
||||
let settings = self.effective
|
||||
let otherSettings = other.effective
|
||||
|
||||
if settings.privateChats.enabled != otherSettings.privateChats.enabled {
|
||||
return false
|
||||
}
|
||||
if settings.groupChats.enabled != otherSettings.groupChats.enabled {
|
||||
return false
|
||||
}
|
||||
if settings.channels.enabled != otherSettings.channels.enabled {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
public init(toBeSynchronized: GlobalNotificationSettingsSet?, remote: GlobalNotificationSettingsSet) {
|
||||
self.toBeSynchronized = toBeSynchronized
|
||||
self.remote = remote
|
||||
|
||||
Reference in New Issue
Block a user