mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-06 21:22:44 +00:00
Use global notification settings in mute state resolution
This commit is contained in:
@@ -2948,7 +2948,9 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
||||
let currentInclusion = transaction.getPeerChatListInclusion(peerId)
|
||||
if let groupId = currentInclusion.groupId, groupId == Namespaces.PeerGroup.archive {
|
||||
if let peer = transaction.getPeer(peerId) as? TelegramSecretChat {
|
||||
if let notificationSettings = transaction.getPeerNotificationSettings(peer.regularPeerId) as? TelegramPeerNotificationSettings, !notificationSettings.isRemovedFromTotalUnreadCount(default: !transaction.getGlobalNotificationSettings().defaultIncludePeer(peer: peer)) {
|
||||
let isRemovedFromTotalUnreadCount = resolvedIsRemovedFromTotalUnreadCount(globalSettings: transaction.getGlobalNotificationSettings(), peer: peer, peerSettings: transaction.getPeerNotificationSettings(peer.regularPeerId))
|
||||
|
||||
if !isRemovedFromTotalUnreadCount {
|
||||
transaction.updatePeerChatListInclusion(peerId, inclusion: currentInclusion.withGroupId(groupId: .root))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,17 @@ public func togglePeerMuted(account: Account, peerId: PeerId) -> Signal<Void, No
|
||||
|
||||
let updatedSettings: TelegramPeerNotificationSettings
|
||||
switch previousSettings.muteState {
|
||||
case .unmuted, .default:
|
||||
case .default:
|
||||
let globalNotificationSettings = transaction.getGlobalNotificationSettings()
|
||||
if resolvedIsRemovedFromTotalUnreadCount(globalSettings: globalNotificationSettings, peer: peer, peerSettings: previousSettings) {
|
||||
updatedSettings = previousSettings.withUpdatedMuteState(.unmuted)
|
||||
} else {
|
||||
updatedSettings = previousSettings.withUpdatedMuteState(.muted(until: Int32.max))
|
||||
case .muted:
|
||||
updatedSettings = previousSettings.withUpdatedMuteState(.default)
|
||||
}
|
||||
case .unmuted:
|
||||
updatedSettings = previousSettings.withUpdatedMuteState(.muted(until: Int32.max))
|
||||
case .muted:
|
||||
updatedSettings = previousSettings.withUpdatedMuteState(.unmuted)
|
||||
}
|
||||
transaction.updatePendingPeerNotificationSettings(peerId: notificationPeerId, settings: updatedSettings)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user