mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 05:03:45 +00:00
PeerContactSettings -> PeerStatusSettings
This commit is contained in:
parent
242ad146b0
commit
b02faa87fe
@ -1159,7 +1159,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
})
|
||||
case let .updatePeerSettings(peer, settings):
|
||||
let peerContactSettings = PeerContactSettings(apiSettings: settings)
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: settings)
|
||||
updatedState.updateCachedPeerData(peer.peerId, { current in
|
||||
if peer.peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
let previous: CachedUserData
|
||||
@ -1168,7 +1168,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
return previous.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if peer.peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
@ -1176,7 +1176,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
} else {
|
||||
previous = CachedGroupData()
|
||||
}
|
||||
return previous.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if peer.peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
let previous: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
@ -1184,7 +1184,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
} else {
|
||||
previous = CachedChannelData()
|
||||
}
|
||||
return previous.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
public let participantsSummary: CachedChannelParticipantsSummary
|
||||
public let exportedInvitation: ExportedInvitation?
|
||||
public let botInfos: [CachedPeerBotInfo]
|
||||
public let peerContactSettings: PeerContactSettings?
|
||||
public let peerStatusSettings: PeerStatusSettings?
|
||||
public let pinnedMessageId: MessageId?
|
||||
public let stickerPack: StickerPackCollectionInfo?
|
||||
public let minAvailableMessageId: MessageId?
|
||||
@ -153,7 +153,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
self.participantsSummary = CachedChannelParticipantsSummary(memberCount: nil, adminCount: nil, bannedCount: nil, kickedCount: nil)
|
||||
self.exportedInvitation = nil
|
||||
self.botInfos = []
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
self.pinnedMessageId = nil
|
||||
self.peerIds = Set()
|
||||
self.messageIds = Set()
|
||||
@ -163,14 +163,14 @@ public final class CachedChannelData: CachedPeerData {
|
||||
self.linkedDiscussionPeerId = nil
|
||||
}
|
||||
|
||||
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerContactSettings: PeerContactSettings?, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, linkedDiscussionPeerId: PeerId?) {
|
||||
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, linkedDiscussionPeerId: PeerId?) {
|
||||
self.isNotAccessible = isNotAccessible
|
||||
self.flags = flags
|
||||
self.about = about
|
||||
self.participantsSummary = participantsSummary
|
||||
self.exportedInvitation = exportedInvitation
|
||||
self.botInfos = botInfos
|
||||
self.peerContactSettings = peerContactSettings
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
self.pinnedMessageId = pinnedMessageId
|
||||
self.stickerPack = stickerPack
|
||||
self.minAvailableMessageId = minAvailableMessageId
|
||||
@ -196,51 +196,51 @@ public final class CachedChannelData: CachedPeerData {
|
||||
}
|
||||
|
||||
func withUpdatedIsNotAccessible(_ isNotAccessible: Bool) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedFlags(_ flags: CachedChannelFlags) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedAbout(_ about: String?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedParticipantsSummary(_ participantsSummary: CachedChannelParticipantsSummary) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedPeerContactSettings(_ peerContactSettings: PeerContactSettings?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedStickerPack(_ stickerPack: StickerPackCollectionInfo?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedMinAvailableMessageId(_ minAvailableMessageId: MessageId?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedMigrationReference(_ migrationReference: ChannelMigrationReference?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
func withUpdatedLinkedDiscussionPeerId(_ linkedDiscussionPeerId: PeerId?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: linkedDiscussionPeerId)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: linkedDiscussionPeerId)
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
@ -252,9 +252,9 @@ public final class CachedChannelData: CachedPeerData {
|
||||
self.botInfos = decoder.decodeObjectArrayWithDecoderForKey("b") as [CachedPeerBotInfo]
|
||||
var peerIds = Set<PeerId>()
|
||||
if let value = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerContactSettings = PeerContactSettings(rawValue: value)
|
||||
self.peerStatusSettings = PeerStatusSettings(rawValue: value)
|
||||
} else {
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
}
|
||||
if let pinnedMessagePeerId = decoder.decodeOptionalInt64ForKey("pm.p"), let pinnedMessageNamespace = decoder.decodeOptionalInt32ForKey("pm.n"), let pinnedMessageId = decoder.decodeOptionalInt32ForKey("pm.i") {
|
||||
self.pinnedMessageId = MessageId(peerId: PeerId(pinnedMessagePeerId), namespace: pinnedMessageNamespace, id: pinnedMessageId)
|
||||
@ -314,8 +314,8 @@ public final class CachedChannelData: CachedPeerData {
|
||||
encoder.encodeNil(forKey: "i")
|
||||
}
|
||||
encoder.encodeObjectArray(self.botInfos, forKey: "b")
|
||||
if let peerContactSettings = self.peerContactSettings {
|
||||
encoder.encodeInt32(peerContactSettings.rawValue, forKey: "pcs")
|
||||
if let peerStatusSettings = self.peerStatusSettings {
|
||||
encoder.encodeInt32(peerStatusSettings.rawValue, forKey: "pcs")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "pcs")
|
||||
}
|
||||
@ -387,7 +387,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
return false
|
||||
}
|
||||
|
||||
if other.peerContactSettings != self.peerContactSettings {
|
||||
if other.peerStatusSettings != self.peerStatusSettings {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public final class CachedGroupData: CachedPeerData {
|
||||
public let participants: CachedGroupParticipants?
|
||||
public let exportedInvitation: ExportedInvitation?
|
||||
public let botInfos: [CachedPeerBotInfo]
|
||||
public let peerContactSettings: PeerContactSettings?
|
||||
public let peerStatusSettings: PeerStatusSettings?
|
||||
public let pinnedMessageId: MessageId?
|
||||
public let about: String?
|
||||
public let flags: CachedGroupFlags
|
||||
@ -60,7 +60,7 @@ public final class CachedGroupData: CachedPeerData {
|
||||
self.participants = nil
|
||||
self.exportedInvitation = nil
|
||||
self.botInfos = []
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
self.pinnedMessageId = nil
|
||||
self.messageIds = Set()
|
||||
self.peerIds = Set()
|
||||
@ -68,11 +68,11 @@ public final class CachedGroupData: CachedPeerData {
|
||||
self.flags = CachedGroupFlags()
|
||||
}
|
||||
|
||||
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerContactSettings: PeerContactSettings?, pinnedMessageId: MessageId?, about: String?, flags: CachedGroupFlags) {
|
||||
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, about: String?, flags: CachedGroupFlags) {
|
||||
self.participants = participants
|
||||
self.exportedInvitation = exportedInvitation
|
||||
self.botInfos = botInfos
|
||||
self.peerContactSettings = peerContactSettings
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
self.pinnedMessageId = pinnedMessageId
|
||||
self.about = about
|
||||
self.flags = flags
|
||||
@ -101,9 +101,9 @@ public final class CachedGroupData: CachedPeerData {
|
||||
self.exportedInvitation = decoder.decodeObjectForKey("i", decoder: { ExportedInvitation(decoder: $0) }) as? ExportedInvitation
|
||||
self.botInfos = decoder.decodeObjectArrayWithDecoderForKey("b") as [CachedPeerBotInfo]
|
||||
if let value = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerContactSettings = PeerContactSettings(rawValue: value)
|
||||
self.peerStatusSettings = PeerStatusSettings(rawValue: value)
|
||||
} else {
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
}
|
||||
if let pinnedMessagePeerId = decoder.decodeOptionalInt64ForKey("pm.p"), let pinnedMessageNamespace = decoder.decodeOptionalInt32ForKey("pm.n"), let pinnedMessageId = decoder.decodeOptionalInt32ForKey("pm.i") {
|
||||
self.pinnedMessageId = MessageId(peerId: PeerId(pinnedMessagePeerId), namespace: pinnedMessageNamespace, id: pinnedMessageId)
|
||||
@ -144,8 +144,8 @@ public final class CachedGroupData: CachedPeerData {
|
||||
encoder.encodeNil(forKey: "i")
|
||||
}
|
||||
encoder.encodeObjectArray(self.botInfos, forKey: "b")
|
||||
if let peerContactSettings = self.peerContactSettings {
|
||||
encoder.encodeInt32(peerContactSettings.rawValue, forKey: "pcs")
|
||||
if let peerStatusSettings = self.peerStatusSettings {
|
||||
encoder.encodeInt32(peerStatusSettings.rawValue, forKey: "pcs")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "pcs")
|
||||
}
|
||||
@ -171,34 +171,34 @@ public final class CachedGroupData: CachedPeerData {
|
||||
return false
|
||||
}
|
||||
|
||||
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.peerContactSettings == other.peerContactSettings && self.pinnedMessageId == other.pinnedMessageId && self.about == other.about && self.flags == other.flags
|
||||
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.peerStatusSettings == other.peerStatusSettings && self.pinnedMessageId == other.pinnedMessageId && self.about == other.about && self.flags == other.flags
|
||||
}
|
||||
|
||||
func withUpdatedParticipants(_ participants: CachedGroupParticipants?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedPeerContactSettings(_ peerContactSettings: PeerContactSettings?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: peerContactSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: pinnedMessageId, about: self.about, flags: self.flags)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedAbout(_ about: String?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, about: about, flags: self.flags)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedFlags(_ flags: CachedGroupFlags) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: flags)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: flags)
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import Foundation
|
||||
public final class CachedUserData: CachedPeerData {
|
||||
public let about: String?
|
||||
public let botInfo: BotInfo?
|
||||
public let peerContactSettings: PeerContactSettings?
|
||||
public let peerStatusSettings: PeerStatusSettings?
|
||||
public let pinnedMessageId: MessageId?
|
||||
public let isBlocked: Bool
|
||||
public let commonGroupCount: Int32
|
||||
@ -23,7 +23,7 @@ public final class CachedUserData: CachedPeerData {
|
||||
init() {
|
||||
self.about = nil
|
||||
self.botInfo = nil
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
self.pinnedMessageId = nil
|
||||
self.isBlocked = false
|
||||
self.commonGroupCount = 0
|
||||
@ -33,10 +33,10 @@ public final class CachedUserData: CachedPeerData {
|
||||
self.messageIds = Set()
|
||||
}
|
||||
|
||||
init(about: String?, botInfo: BotInfo?, peerContactSettings: PeerContactSettings?, pinnedMessageId: MessageId?, isBlocked: Bool, commonGroupCount: Int32, callsAvailable: Bool, callsPrivate: Bool, canPinMessages: Bool) {
|
||||
init(about: String?, botInfo: BotInfo?, peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, isBlocked: Bool, commonGroupCount: Int32, callsAvailable: Bool, callsPrivate: Bool, canPinMessages: Bool) {
|
||||
self.about = about
|
||||
self.botInfo = botInfo
|
||||
self.peerContactSettings = peerContactSettings
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
self.pinnedMessageId = pinnedMessageId
|
||||
self.isBlocked = isBlocked
|
||||
self.commonGroupCount = commonGroupCount
|
||||
@ -54,9 +54,9 @@ public final class CachedUserData: CachedPeerData {
|
||||
self.about = decoder.decodeOptionalStringForKey("a")
|
||||
self.botInfo = decoder.decodeObjectForKey("bi") as? BotInfo
|
||||
if let value = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerContactSettings = PeerContactSettings(rawValue: value)
|
||||
self.peerStatusSettings = PeerStatusSettings(rawValue: value)
|
||||
} else {
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
}
|
||||
if let pinnedMessagePeerId = decoder.decodeOptionalInt64ForKey("pm.p"), let pinnedMessageNamespace = decoder.decodeOptionalInt32ForKey("pm.n"), let pinnedMessageId = decoder.decodeOptionalInt32ForKey("pm.i") {
|
||||
self.pinnedMessageId = MessageId(peerId: PeerId(pinnedMessagePeerId), namespace: pinnedMessageNamespace, id: pinnedMessageId)
|
||||
@ -87,8 +87,8 @@ public final class CachedUserData: CachedPeerData {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "bi")
|
||||
}
|
||||
if let peerContactSettings = self.peerContactSettings {
|
||||
encoder.encodeInt32(peerContactSettings.rawValue, forKey: "pcs")
|
||||
if let peerStatusSettings = self.peerStatusSettings {
|
||||
encoder.encodeInt32(peerStatusSettings.rawValue, forKey: "pcs")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "pcs")
|
||||
}
|
||||
@ -120,42 +120,42 @@ public final class CachedUserData: CachedPeerData {
|
||||
return false
|
||||
}
|
||||
|
||||
return other.about == self.about && other.botInfo == self.botInfo && self.peerContactSettings == other.peerContactSettings && self.isBlocked == other.isBlocked && self.commonGroupCount == other.commonGroupCount && self.callsAvailable == other.callsAvailable && self.callsPrivate == other.callsPrivate
|
||||
return other.about == self.about && other.botInfo == self.botInfo && self.peerStatusSettings == other.peerStatusSettings && self.isBlocked == other.isBlocked && self.commonGroupCount == other.commonGroupCount && self.callsAvailable == other.callsAvailable && self.callsPrivate == other.callsPrivate
|
||||
}
|
||||
|
||||
func withUpdatedAbout(_ about: String?) -> CachedUserData {
|
||||
return CachedUserData(about: about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedBotInfo(_ botInfo: BotInfo?) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedPeerContactSettings(_ peerContactSettings: PeerContactSettings) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedIsBlocked(_ isBlocked: Bool) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedCommonGroupCount(_ commonGroupCount: Int32) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedCallsAvailable(_ callsAvailable: Bool) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedCallsPrivate(_ callsPrivate: Bool) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: callsPrivate, canPinMessages: self.canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: callsPrivate, canPinMessages: self.canPinMessages)
|
||||
}
|
||||
|
||||
func withUpdatedCanPinMessages(_ canPinMessages: Bool) -> CachedUserData {
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerContactSettings: self.peerContactSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: canPinMessages)
|
||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: canPinMessages)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1380,9 +1380,9 @@ private func requestTerminateSecretChat(postbox: Postbox, network: Network, peer
|
||||
if result != nil {
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
if let current = current as? CachedSecretChatData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
|
||||
@ -5,23 +5,23 @@ import Foundation
|
||||
import Postbox
|
||||
#endif
|
||||
|
||||
public struct PeerContactSettings: OptionSet {
|
||||
public struct PeerStatusSettings: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let isHidden = PeerContactSettings(rawValue: 1 << 0)
|
||||
public static let canReport = PeerContactSettings(rawValue: 1 << 1)
|
||||
public static let canShareContact = PeerContactSettings(rawValue: 1 << 2)
|
||||
public static let isHidden = PeerStatusSettings(rawValue: 1 << 0)
|
||||
public static let canReport = PeerStatusSettings(rawValue: 1 << 1)
|
||||
public static let canShareContact = PeerStatusSettings(rawValue: 1 << 2)
|
||||
}
|
||||
|
||||
extension PeerContactSettings {
|
||||
extension PeerStatusSettings {
|
||||
init(apiSettings: Api.PeerSettings) {
|
||||
switch apiSettings {
|
||||
case let .peerSettings(flags):
|
||||
var result = PeerContactSettings()
|
||||
var result = PeerStatusSettings()
|
||||
if (flags & (1 << 1)) != 0 {
|
||||
result.insert(.isHidden)
|
||||
}
|
||||
|
||||
@ -27,20 +27,20 @@ public func reportPeer(account: Account, peerId: PeerId) -> Signal<Void, NoError
|
||||
if result != nil {
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
if let current = current as? CachedUserData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.remove(.canReport)
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.remove(.canReport)
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedGroupData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.remove(.canReport)
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.remove(.canReport)
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedChannelData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.remove(.canReport)
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.remove(.canReport)
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
@ -59,20 +59,20 @@ public func reportPeer(account: Account, peerId: PeerId) -> Signal<Void, NoError
|
||||
if result != nil {
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
if let current = current as? CachedUserData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.remove(.canReport)
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.remove(.canReport)
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedGroupData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.remove(.canReport)
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.remove(.canReport)
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedChannelData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.remove(.canReport)
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.remove(.canReport)
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
@ -172,25 +172,25 @@ public func reportSupergroupPeer(account: Account, peerId: PeerId, memberId: Pee
|
||||
} |> switchToLatest
|
||||
}
|
||||
|
||||
public func dismissPeerContactOptions(account: Account, peerId: PeerId) -> Signal<Void, NoError> {
|
||||
public func dismissPeerStatusOptions(account: Account, peerId: PeerId) -> Signal<Void, NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
if let current = current as? CachedUserData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedGroupData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedChannelData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else if let current = current as? CachedSecretChatData {
|
||||
var peerContactSettings = current.peerContactSettings ?? PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
var peerStatusSettings = current.peerStatusSettings ?? PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
|
||||
@ -81,23 +81,23 @@ public final class CachedSecretChatData: CachedPeerData {
|
||||
public let messageIds: Set<MessageId> = Set()
|
||||
public let associatedHistoryMessageId: MessageId? = nil
|
||||
|
||||
public let peerContactSettings: PeerContactSettings?
|
||||
public let peerStatusSettings: PeerStatusSettings?
|
||||
|
||||
public init(peerContactSettings: PeerContactSettings?) {
|
||||
self.peerContactSettings = peerContactSettings
|
||||
public init(peerStatusSettings: PeerStatusSettings?) {
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
if let value = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerContactSettings = PeerContactSettings(rawValue: value)
|
||||
self.peerStatusSettings = PeerStatusSettings(rawValue: value)
|
||||
} else {
|
||||
self.peerContactSettings = nil
|
||||
self.peerStatusSettings = nil
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
if let peerContactSettings = self.peerContactSettings {
|
||||
encoder.encodeInt32(peerContactSettings.rawValue, forKey: "pcs")
|
||||
if let peerStatusSettings = self.peerStatusSettings {
|
||||
encoder.encodeInt32(peerStatusSettings.rawValue, forKey: "pcs")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "pcs")
|
||||
}
|
||||
@ -105,13 +105,13 @@ public final class CachedSecretChatData: CachedPeerData {
|
||||
|
||||
public func isEqual(to: CachedPeerData) -> Bool {
|
||||
if let to = to as? CachedSecretChatData {
|
||||
return self.peerContactSettings == to.peerContactSettings
|
||||
return self.peerStatusSettings == to.peerStatusSettings
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func withUpdatedPeerContactSettings(_ peerContactSettings: PeerContactSettings) -> CachedSecretChatData {
|
||||
return CachedSecretChatData(peerContactSettings: peerContactSettings)
|
||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings) -> CachedSecretChatData {
|
||||
return CachedSecretChatData(peerStatusSettings: peerStatusSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,44 +13,44 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId: PeerId, network: Network,
|
||||
let cachedData = transaction.getPeerCachedData(peerId: peerId)
|
||||
|
||||
if let cachedData = cachedData as? CachedUserData {
|
||||
if cachedData.peerContactSettings != nil {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedGroupData {
|
||||
if cachedData.peerContactSettings != nil {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedChannelData {
|
||||
if cachedData.peerContactSettings != nil {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedSecretChatData {
|
||||
if cachedData.peerContactSettings != nil {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
||||
if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
var peerContactSettings: PeerContactSettings
|
||||
var peerStatusSettings: PeerStatusSettings
|
||||
if let peer = transaction.getPeer(peerId), let associatedPeerId = peer.associatedPeerId, !transaction.isPeerContact(peerId: associatedPeerId) {
|
||||
if let peer = peer as? TelegramSecretChat, case .creator = peer.role {
|
||||
peerContactSettings = PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
} else {
|
||||
peerContactSettings = PeerContactSettings()
|
||||
peerContactSettings.insert(.canReport)
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings.insert(.canReport)
|
||||
}
|
||||
} else {
|
||||
peerContactSettings = PeerContactSettings()
|
||||
peerContactSettings.insert(.isHidden)
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings.insert(.isHidden)
|
||||
}
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, current in
|
||||
if let current = current as? CachedSecretChatData {
|
||||
return current.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return CachedSecretChatData(peerContactSettings: peerContactSettings)
|
||||
return CachedSecretChatData(peerStatusSettings: peerStatusSettings)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -58,7 +58,7 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId: PeerId, network: Network,
|
||||
return network.request(Api.functions.messages.getPeerSettings(peer: inputPeer))
|
||||
|> retryRequest
|
||||
|> mapToSignal { peerSettings -> Signal<Void, NoError> in
|
||||
let peerContactSettings = PeerContactSettings(apiSettings: peerSettings)
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: peerSettings)
|
||||
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
@ -70,7 +70,7 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId: PeerId, network: Network,
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
return previous.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
case Namespaces.Peer.CloudGroup:
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
@ -78,7 +78,7 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId: PeerId, network: Network,
|
||||
} else {
|
||||
previous = CachedGroupData()
|
||||
}
|
||||
return previous.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
case Namespaces.Peer.CloudChannel:
|
||||
let previous: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
@ -86,7 +86,7 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId: PeerId, network: Network,
|
||||
} else {
|
||||
previous = CachedChannelData()
|
||||
}
|
||||
return previous.withUpdatedPeerContactSettings(peerContactSettings)
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -138,9 +138,9 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
let canPinMessages = (userFull.flags & (1 << 7)) != 0
|
||||
let pinnedMessageId = userFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||
|
||||
let peerContactSettings = PeerContactSettings(apiSettings: userFull.settings)
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: userFull.settings)
|
||||
|
||||
return previous.withUpdatedAbout(userFull.about).withUpdatedBotInfo(botInfo).withUpdatedCommonGroupCount(userFull.commonChatsCount).withUpdatedIsBlocked(isBlocked).withUpdatedCallsAvailable(callsAvailable).withUpdatedCallsPrivate(callsPrivate).withUpdatedCanPinMessages(canPinMessages).withUpdatedPeerContactSettings(peerContactSettings).withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
return previous.withUpdatedAbout(userFull.about).withUpdatedBotInfo(botInfo).withUpdatedCommonGroupCount(userFull.commonChatsCount).withUpdatedIsBlocked(isBlocked).withUpdatedCallsAvailable(callsAvailable).withUpdatedCallsPrivate(callsPrivate).withUpdatedCanPinMessages(canPinMessages).withUpdatedPeerStatusSettings(peerStatusSettings).withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user