mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-02 04:38:33 +00:00
no message
This commit is contained in:
parent
33b2a2e0da
commit
bf311fed75
@ -7,6 +7,31 @@ import Foundation
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public func togglePeerMuted(account: Account, peerId: PeerId) -> Signal<Void, NoError> {
|
||||||
|
return account.postbox.modify { modifier -> Signal<Void, NoError> in
|
||||||
|
if let peer = modifier.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||||
|
let currentSettings = modifier.getPeerNotificationSettings(peerId) as? TelegramPeerNotificationSettings
|
||||||
|
let previousSettings: TelegramPeerNotificationSettings
|
||||||
|
if let currentSettings = currentSettings {
|
||||||
|
previousSettings = currentSettings
|
||||||
|
} else {
|
||||||
|
previousSettings = TelegramPeerNotificationSettings.defaultSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
let updatedSettings: TelegramPeerNotificationSettings
|
||||||
|
switch previousSettings.muteState {
|
||||||
|
case .unmuted:
|
||||||
|
updatedSettings = previousSettings.withUpdatedMuteState(.muted(until: Int32.max))
|
||||||
|
case .muted:
|
||||||
|
updatedSettings = previousSettings.withUpdatedMuteState(.unmuted)
|
||||||
|
}
|
||||||
|
return changePeerNotificationSettings(account: account, peerId: peerId, settings: updatedSettings)
|
||||||
|
} else {
|
||||||
|
return .complete()
|
||||||
|
}
|
||||||
|
} |> switchToLatest
|
||||||
|
}
|
||||||
|
|
||||||
public func changePeerNotificationSettings(account: Account, peerId: PeerId, settings: TelegramPeerNotificationSettings) -> Signal<Void, NoError> {
|
public func changePeerNotificationSettings(account: Account, peerId: PeerId, settings: TelegramPeerNotificationSettings) -> Signal<Void, NoError> {
|
||||||
return account.postbox.loadedPeerWithId(peerId)
|
return account.postbox.loadedPeerWithId(peerId)
|
||||||
|> mapToSignal { peer -> Signal<Void, NoError> in
|
|> mapToSignal { peer -> Signal<Void, NoError> in
|
||||||
|
|||||||
@ -13,7 +13,12 @@ public func removePeerChat(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoE
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
cloudChatAddRemoveChatOperation(modifier: modifier, peerId: peerId)
|
cloudChatAddRemoveChatOperation(modifier: modifier, peerId: peerId)
|
||||||
}
|
if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||||
|
modifier.updatePeerChatListInclusion(peerId, inclusion: .ifHasMessages)
|
||||||
|
modifier.clearHistory(peerId)
|
||||||
|
} else {
|
||||||
modifier.updatePeerChatListInclusion(peerId, inclusion: .never)
|
modifier.updatePeerChatListInclusion(peerId, inclusion: .never)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -152,6 +152,14 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, E
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func withUpdatedMuteState(_ muteState: PeerMuteState) -> TelegramPeerNotificationSettings {
|
||||||
|
return TelegramPeerNotificationSettings(muteState: muteState, messageSound: self.messageSound)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func withUpdatedMessageSound(_ messageSound: PeerMessageSound) -> TelegramPeerNotificationSettings {
|
||||||
|
return TelegramPeerNotificationSettings(muteState: self.muteState, messageSound: messageSound)
|
||||||
|
}
|
||||||
|
|
||||||
public static func ==(lhs: TelegramPeerNotificationSettings, rhs: TelegramPeerNotificationSettings) -> Bool {
|
public static func ==(lhs: TelegramPeerNotificationSettings, rhs: TelegramPeerNotificationSettings) -> Bool {
|
||||||
return lhs.muteState == rhs.muteState && lhs.messageSound == rhs.messageSound
|
return lhs.muteState == rhs.muteState && lhs.messageSound == rhs.messageSound
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,9 @@ public func updatePeers(modifier: Modifier, peers: [Peer], update: (Peer?, Peer)
|
|||||||
}
|
}
|
||||||
case Namespaces.Peer.CloudGroup:
|
case Namespaces.Peer.CloudGroup:
|
||||||
if let group = updated as? TelegramGroup {
|
if let group = updated as? TelegramGroup {
|
||||||
|
if group.flags.contains(.deactivated) {
|
||||||
|
updatedInclusion = .never
|
||||||
|
} else {
|
||||||
switch group.membership {
|
switch group.membership {
|
||||||
case .Member:
|
case .Member:
|
||||||
if group.creationDate != 0 {
|
if group.creationDate != 0 {
|
||||||
@ -32,6 +35,7 @@ public func updatePeers(modifier: Modifier, peers: [Peer], update: (Peer?, Peer)
|
|||||||
updatedInclusion = .never
|
updatedInclusion = .never
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertionFailure()
|
assertionFailure()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user