mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 19:35:08 +00:00
Discussion group updates
This commit is contained in:
parent
df5653b780
commit
fe13574c44
@ -742,7 +742,6 @@ public final class AccountViewTracker {
|
|||||||
func forceUpdateCachedPeerData(peerId: PeerId) {
|
func forceUpdateCachedPeerData(peerId: PeerId) {
|
||||||
self.queue.async {
|
self.queue.async {
|
||||||
let context: PeerCachedDataContext
|
let context: PeerCachedDataContext
|
||||||
var dataUpdated = false
|
|
||||||
if let existingContext = self.cachedDataContexts[peerId] {
|
if let existingContext = self.cachedDataContexts[peerId] {
|
||||||
context = existingContext
|
context = existingContext
|
||||||
} else {
|
} else {
|
||||||
@ -928,7 +927,14 @@ public final class AccountViewTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrappedPeerViewSignal(peerId: PeerId, signal: Signal<PeerView, NoError>) -> Signal<PeerView, NoError> {
|
func wrappedPeerViewSignal(peerId: PeerId, signal: Signal<PeerView, NoError>, updateData: Bool) -> Signal<PeerView, NoError> {
|
||||||
|
if updateData {
|
||||||
|
self.queue.async {
|
||||||
|
if let existingContext = self.cachedDataContexts[peerId] {
|
||||||
|
existingContext.timestamp = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return withState(signal, { [weak self] () -> Int32 in
|
return withState(signal, { [weak self] () -> Int32 in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
return OSAtomicIncrement32(&strongSelf.nextViewId)
|
return OSAtomicIncrement32(&strongSelf.nextViewId)
|
||||||
@ -946,9 +952,9 @@ public final class AccountViewTracker {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public func peerView(_ peerId: PeerId) -> Signal<PeerView, NoError> {
|
public func peerView(_ peerId: PeerId, updateData: Bool = false) -> Signal<PeerView, NoError> {
|
||||||
if let account = self.account {
|
if let account = self.account {
|
||||||
return wrappedPeerViewSignal(peerId: peerId, signal: account.postbox.peerView(id: peerId))
|
return wrappedPeerViewSignal(peerId: peerId, signal: account.postbox.peerView(id: peerId), updateData: updateData)
|
||||||
} else {
|
} else {
|
||||||
return .never()
|
return .never()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,7 +138,7 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
public let minAvailableMessageId: MessageId?
|
public let minAvailableMessageId: MessageId?
|
||||||
public let migrationReference: ChannelMigrationReference?
|
public let migrationReference: ChannelMigrationReference?
|
||||||
|
|
||||||
public let associatedPeerId:PeerId?
|
public let linkedDiscussionPeerId: PeerId?
|
||||||
|
|
||||||
public let peerIds: Set<PeerId>
|
public let peerIds: Set<PeerId>
|
||||||
public let messageIds: Set<MessageId>
|
public let messageIds: Set<MessageId>
|
||||||
@ -160,10 +160,10 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
self.stickerPack = nil
|
self.stickerPack = nil
|
||||||
self.minAvailableMessageId = nil
|
self.minAvailableMessageId = nil
|
||||||
self.migrationReference = nil
|
self.migrationReference = nil
|
||||||
self.associatedPeerId = nil
|
self.linkedDiscussionPeerId = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, associatedPeerId: PeerId?) {
|
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, linkedDiscussionPeerId: PeerId?) {
|
||||||
self.isNotAccessible = isNotAccessible
|
self.isNotAccessible = isNotAccessible
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
self.about = about
|
self.about = about
|
||||||
@ -175,15 +175,15 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
self.stickerPack = stickerPack
|
self.stickerPack = stickerPack
|
||||||
self.minAvailableMessageId = minAvailableMessageId
|
self.minAvailableMessageId = minAvailableMessageId
|
||||||
self.migrationReference = migrationReference
|
self.migrationReference = migrationReference
|
||||||
self.associatedPeerId = associatedPeerId
|
self.linkedDiscussionPeerId = linkedDiscussionPeerId
|
||||||
|
|
||||||
var peerIds = Set<PeerId>()
|
var peerIds = Set<PeerId>()
|
||||||
for botInfo in botInfos {
|
for botInfo in botInfos {
|
||||||
peerIds.insert(botInfo.peerId)
|
peerIds.insert(botInfo.peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let associatedPeerId = associatedPeerId {
|
if let linkedDiscussionPeerId = linkedDiscussionPeerId {
|
||||||
peerIds.insert(associatedPeerId)
|
peerIds.insert(linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.peerIds = peerIds
|
self.peerIds = peerIds
|
||||||
@ -196,51 +196,51 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedIsNotAccessible(_ isNotAccessible: Bool) -> CachedChannelData {
|
func withUpdatedIsNotAccessible(_ isNotAccessible: Bool) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedFlags(_ flags: CachedChannelFlags) -> CachedChannelData {
|
func withUpdatedFlags(_ flags: CachedChannelFlags) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedAbout(_ about: String?) -> CachedChannelData {
|
func withUpdatedAbout(_ about: String?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedParticipantsSummary(_ participantsSummary: CachedChannelParticipantsSummary) -> CachedChannelData {
|
func withUpdatedParticipantsSummary(_ participantsSummary: CachedChannelParticipantsSummary) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedChannelData {
|
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedChannelData {
|
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedReportStatus(_ reportStatus: PeerReportStatus) -> CachedChannelData {
|
func withUpdatedReportStatus(_ reportStatus: PeerReportStatus) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedChannelData {
|
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, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedStickerPack(_ stickerPack: StickerPackCollectionInfo?) -> CachedChannelData {
|
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, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMinAvailableMessageId(_ minAvailableMessageId: MessageId?) -> CachedChannelData {
|
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, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMigrationReference(_ migrationReference: ChannelMigrationReference?) -> CachedChannelData {
|
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, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, associatedPeerId: self.associatedPeerId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedAssociatedPeerId(_ groupId: PeerId?) -> CachedChannelData {
|
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, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, associatedPeerId: groupId)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
@ -276,14 +276,14 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
peerIds.insert(botInfo.peerId)
|
peerIds.insert(botInfo.peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let associatedPeerId = decoder.decodeOptionalInt64ForKey("dgi") {
|
if let linkedDiscussionPeerId = decoder.decodeOptionalInt64ForKey("dgi") {
|
||||||
self.associatedPeerId = PeerId(associatedPeerId)
|
self.linkedDiscussionPeerId = PeerId(linkedDiscussionPeerId)
|
||||||
} else {
|
} else {
|
||||||
self.associatedPeerId = nil
|
self.linkedDiscussionPeerId = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if let associatedPeerId = associatedPeerId {
|
if let linkedDiscussionPeerId = self.linkedDiscussionPeerId {
|
||||||
peerIds.insert(associatedPeerId)
|
peerIds.insert(linkedDiscussionPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.peerIds = peerIds
|
self.peerIds = peerIds
|
||||||
@ -293,8 +293,6 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
messageIds.insert(pinnedMessageId)
|
messageIds.insert(pinnedMessageId)
|
||||||
}
|
}
|
||||||
self.messageIds = messageIds
|
self.messageIds = messageIds
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
@ -341,8 +339,8 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "mr")
|
encoder.encodeNil(forKey: "mr")
|
||||||
}
|
}
|
||||||
if let associatedPeerId = self.associatedPeerId {
|
if let linkedDiscussionPeerId = self.linkedDiscussionPeerId {
|
||||||
encoder.encodeInt64(associatedPeerId.toInt64(), forKey: "dgi")
|
encoder.encodeInt64(linkedDiscussionPeerId.toInt64(), forKey: "dgi")
|
||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "dgi")
|
encoder.encodeNil(forKey: "dgi")
|
||||||
}
|
}
|
||||||
@ -361,7 +359,7 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if other.associatedPeerId != self.associatedPeerId {
|
if other.linkedDiscussionPeerId != self.linkedDiscussionPeerId {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,7 @@ public enum AdminLogEventAction {
|
|||||||
case updateDefaultBannedRights(prev: TelegramChatBannedRights, new: TelegramChatBannedRights
|
case updateDefaultBannedRights(prev: TelegramChatBannedRights, new: TelegramChatBannedRights
|
||||||
)
|
)
|
||||||
case pollStopped(Message)
|
case pollStopped(Message)
|
||||||
|
case linkedPeerUpdated(previous: Peer?, updated: Peer?)
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ChannelAdminLogEventError {
|
public enum ChannelAdminLogEventError {
|
||||||
@ -208,7 +209,7 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
|
|||||||
action = .pollStopped(rendered)
|
action = .pollStopped(rendered)
|
||||||
}
|
}
|
||||||
case let .channelAdminLogEventActionChangeLinkedChat(prevValue, newValue):
|
case let .channelAdminLogEventActionChangeLinkedChat(prevValue, newValue):
|
||||||
break
|
action = .linkedPeerUpdated(previous: prevValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: prevValue)], updated: newValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: newValue)])
|
||||||
}
|
}
|
||||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||||
if let action = action {
|
if let action = action {
|
||||||
|
|||||||
@ -223,6 +223,9 @@ final class ChatHistoryPreloadManager {
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
var indices: [(ChatHistoryPreloadIndex, Bool, Bool)] = []
|
var indices: [(ChatHistoryPreloadIndex, Bool, Bool)] = []
|
||||||
for entry in view.0.entries {
|
for entry in view.0.entries {
|
||||||
if case let .MessageEntry(index, _, readState, notificationSettings, _, _, _, _) = entry {
|
if case let .MessageEntry(index, _, readState, notificationSettings, _, _, _, _) = entry {
|
||||||
|
|||||||
@ -56,8 +56,6 @@ public enum ChannelDiscussionGroupError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//channels.setDiscussionGroup broadcast:InputChannel group:InputChannel = Bool;
|
|
||||||
public func updateGroupDiscussionForChannel(network: Network, postbox: Postbox, channelId: PeerId, groupId: PeerId?) -> Signal<Bool, ChannelDiscussionGroupError> {
|
public func updateGroupDiscussionForChannel(network: Network, postbox: Postbox, channelId: PeerId, groupId: PeerId?) -> Signal<Bool, ChannelDiscussionGroupError> {
|
||||||
|
|
||||||
return postbox.transaction { transaction -> (channel: Peer?, group: Peer?) in
|
return postbox.transaction { transaction -> (channel: Peer?, group: Peer?) in
|
||||||
@ -81,18 +79,31 @@ public func updateGroupDiscussionForChannel(network: Network, postbox: Postbox,
|
|||||||
}
|
}
|
||||||
|> map { result in
|
|> map { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .boolTrue:
|
case .boolTrue:
|
||||||
return true
|
return true
|
||||||
case .boolFalse:
|
case .boolFalse:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} |> mapToSignal { result in
|
} |> mapToSignal { result in
|
||||||
if result {
|
if result {
|
||||||
return postbox.transaction { transaction in
|
return postbox.transaction { transaction in
|
||||||
|
var previousGroupId: PeerId?
|
||||||
transaction.updatePeerCachedData(peerIds: Set([channelId]), update: { (_, current) -> CachedPeerData? in
|
transaction.updatePeerCachedData(peerIds: Set([channelId]), update: { (_, current) -> CachedPeerData? in
|
||||||
return (current as? CachedChannelData ?? CachedChannelData()).withUpdatedAssociatedPeerId(groupId)
|
let current: CachedChannelData = current as? CachedChannelData ?? CachedChannelData()
|
||||||
|
previousGroupId = current.linkedDiscussionPeerId
|
||||||
|
return current.withUpdatedLinkedDiscussionPeerId(groupId)
|
||||||
})
|
})
|
||||||
|
if let previousGroupId = previousGroupId {
|
||||||
|
transaction.updatePeerCachedData(peerIds: Set([previousGroupId]), update: { (_, current) -> CachedPeerData? in
|
||||||
|
return (current as? CachedChannelData ?? CachedChannelData()).withUpdatedLinkedDiscussionPeerId(nil)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if let groupId = groupId {
|
||||||
|
transaction.updatePeerCachedData(peerIds: Set([groupId]), update: { (_, current) -> CachedPeerData? in
|
||||||
|
return (current as? CachedChannelData ?? CachedChannelData()).withUpdatedLinkedDiscussionPeerId(channelId)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|> introduceError(ChannelDiscussionGroupError.self)
|
|> introduceError(ChannelDiscussionGroupError.self)
|
||||||
|> map { _ in
|
|> map { _ in
|
||||||
|
|||||||
@ -271,12 +271,12 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
|||||||
channelFlags.insert(.canSetStickerSet)
|
channelFlags.insert(.canSetStickerSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
let associatedPeerId: PeerId?
|
let linkedDiscussionPeerId: PeerId?
|
||||||
|
|
||||||
if let linkedChatId = linkedChatId {
|
if let linkedChatId = linkedChatId {
|
||||||
associatedPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: linkedChatId)
|
linkedDiscussionPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: linkedChatId)
|
||||||
} else {
|
} else {
|
||||||
associatedPeerId = nil
|
linkedDiscussionPeerId = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var botInfos: [CachedPeerBotInfo] = []
|
var botInfos: [CachedPeerBotInfo] = []
|
||||||
@ -365,7 +365,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
|||||||
.withUpdatedStickerPack(stickerPack)
|
.withUpdatedStickerPack(stickerPack)
|
||||||
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
||||||
.withUpdatedMigrationReference(migrationReference)
|
.withUpdatedMigrationReference(migrationReference)
|
||||||
.withUpdatedAssociatedPeerId(associatedPeerId)
|
.withUpdatedLinkedDiscussionPeerId(linkedDiscussionPeerId)
|
||||||
})
|
})
|
||||||
|
|
||||||
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user