diff --git a/TelegramCore/PendingMessageManager.swift b/TelegramCore/PendingMessageManager.swift index 77d9873395..38dffd83fd 100644 --- a/TelegramCore/PendingMessageManager.swift +++ b/TelegramCore/PendingMessageManager.swift @@ -300,6 +300,12 @@ public final class PendingMessageManager { } else { messageContext.state = .waitingForUploadToStart(groupId: message.groupingKey, upload: contentUploadSignal) } + + if let _ = currentGroupId, message.groupingKey != currentGroupId { + currentGroupId = nil + } else { + currentGroupId = message.groupingKey + } } if let currentGroupId = currentGroupId { @@ -469,9 +475,9 @@ public final class PendingMessageManager { if let current = strongSelf.messageContexts[id] { strongSelf.beginSendingMessage(messageContext: current, messageId: id, groupId: groupId, content: content) strongSelf.updateWaitingUploads(peerId: id.peerId) - if let groupId = groupId { - strongSelf.beginSendingGroupIfPossible(groupId: groupId) - } + //if let groupId = groupId { + // strongSelf.beginSendingGroupIfPossible(groupId: groupId) + // } } } } diff --git a/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift b/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift index ff38129214..99d5afaef7 100644 --- a/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift +++ b/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift @@ -819,14 +819,15 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 if let file = file { let fileMedia = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.CloudSecretFile, id: file.id), partialReference: nil, resource: file.resource(key: SecretFileEncryptionKey(aesKey: key.makeData(), aesIv: iv.makeData()), decryptedSize: size), previewRepresentations: [], mimeType: mimeType, size: Int(size), attributes: [TelegramMediaFileAttribute.Audio(isVoice: true, duration: Int(duration), title: nil, performer: nil, waveform: nil)]) parsedMedia.append(fileMedia) + attributes.append(ConsumableContentMessageAttribute(consumed: false)) } - case let .decryptedMessageMediaDocument(thumb, thumbW, thumbH, mimeType, size, key, iv, attributes, caption): + case let .decryptedMessageMediaDocument(thumb, thumbW, thumbH, mimeType, size, key, iv, decryptedAttributes, caption): if !caption.isEmpty { text = caption } if let file = file { var parsedAttributes: [TelegramMediaFileAttribute] = [] - for attribute in attributes { + for attribute in decryptedAttributes { if let parsedAttribute = TelegramMediaFileAttribute(attribute) { parsedAttributes.append(parsedAttribute) } @@ -839,6 +840,22 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 } let fileMedia = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.CloudSecretFile, id: file.id), partialReference: nil, resource: file.resource(key: SecretFileEncryptionKey(aesKey: key.makeData(), aesIv: iv.makeData()), decryptedSize: size), previewRepresentations: previewRepresentations, mimeType: mimeType, size: Int(size), attributes: parsedAttributes) parsedMedia.append(fileMedia) + + loop: for attr in parsedAttributes { + switch attr { + case let .Video(_, _, flags): + if flags.contains(.instantRoundVideo) { + attributes.append(ConsumableContentMessageAttribute(consumed: false)) + } + break loop + case let .Audio(isVoice, _, _, _, _): + if isVoice { + attributes.append(ConsumableContentMessageAttribute(consumed: false)) + } + default: + break + } + } } case let .decryptedMessageMediaVideo(thumb, thumbW, thumbH, duration, mimeType, w, h, size, key, iv, caption): if !caption.isEmpty { diff --git a/TelegramCore/UpdateCachedPeerData.swift b/TelegramCore/UpdateCachedPeerData.swift index 50a1ae9d1e..47cc25c604 100644 --- a/TelegramCore/UpdateCachedPeerData.swift +++ b/TelegramCore/UpdateCachedPeerData.swift @@ -224,7 +224,9 @@ func fetchAndUpdateCachedPeerData(peerId: PeerId, network: Network, postbox: Pos } switch fullChat { - case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId): + // case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo], migratedFromChatId: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?) + + case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, apiReadInboxMaxId, apiReadOutboxMaxId, apiUnreadCount, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId): var channelFlags = CachedChannelFlags() if (flags & (1 << 3)) != 0 { channelFlags.insert(.canDisplayParticipants) @@ -288,6 +290,22 @@ func fetchAndUpdateCachedPeerData(peerId: PeerId, network: Network, postbox: Pos transaction.updatePeerPresences(peerPresences) + +// let readState = transaction.getReadState(peerId) +// +// let hasReadState: Bool = false//readState?.hasNamespace(Namespaces.Message.Cloud) ?? false +// +// if !hasReadState { +// var readStates: [PeerId: [MessageId.Namespace: PeerReadState]] = [:] +// if readStates[peerId] == nil { +// readStates[peerId] = [:] +// } +// readStates[peerId]![Namespaces.Message.Cloud] = .idBased(maxIncomingReadId: apiReadInboxMaxId, maxOutgoingReadId: apiReadOutboxMaxId, maxKnownId: readState?.maxKnownId ?? 0, count: apiUnreadCount, markedUnread: readState?.markedUnread ?? false) +// transaction.resetIncomingReadStates(readStates) +// } +// + + let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in let namespace: ItemCollectionId.Namespace switch apiSet {