mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Emoji and reaction improvements
This commit is contained in:
parent
13335196c4
commit
36e6a73b3b
@ -462,8 +462,27 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
|
|||||||
if !entities.isEmpty {
|
if !entities.isEmpty {
|
||||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||||
}
|
}
|
||||||
|
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||||
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: []), uniqueId: item.uniqueId, isFile: false))
|
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||||
|
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||||
|
if let file = value.file {
|
||||||
|
if let packId = value.interactivelySelectedFromPackId {
|
||||||
|
bubbleUpEmojiOrStickersetsById[file.fileId.id] = packId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||||
|
for entity in entities {
|
||||||
|
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||||
|
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||||
|
if !bubbleUpEmojiOrStickersets.contains(packId) {
|
||||||
|
bubbleUpEmojiOrStickersets.append(packId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: bubbleUpEmojiOrStickersets), uniqueId: item.uniqueId, isFile: false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .asset(asset):
|
case let .asset(asset):
|
||||||
@ -485,8 +504,29 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
|
|||||||
if !entities.isEmpty {
|
if !entities.isEmpty {
|
||||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||||
|
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||||
|
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||||
|
if let file = value.file {
|
||||||
|
if let packId = value.interactivelySelectedFromPackId {
|
||||||
|
bubbleUpEmojiOrStickersetsById[file.fileId.id] = packId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||||
|
for entity in entities {
|
||||||
|
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||||
|
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||||
|
if !bubbleUpEmojiOrStickersets.contains(packId) {
|
||||||
|
bubbleUpEmojiOrStickersets.append(packId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: []), uniqueId: item.uniqueId, isFile: false))
|
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: bubbleUpEmojiOrStickersets), uniqueId: item.uniqueId, isFile: false))
|
||||||
case .tempFile:
|
case .tempFile:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -515,8 +555,29 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
|
|||||||
if !entities.isEmpty {
|
if !entities.isEmpty {
|
||||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||||
|
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||||
|
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||||
|
if let file = value.file {
|
||||||
|
if let packId = value.interactivelySelectedFromPackId {
|
||||||
|
bubbleUpEmojiOrStickersetsById[file.fileId.id] = packId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||||
|
for entity in entities {
|
||||||
|
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||||
|
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||||
|
if !bubbleUpEmojiOrStickersets.contains(packId) {
|
||||||
|
bubbleUpEmojiOrStickersets.append(packId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: []), uniqueId: item.uniqueId, isFile: true))
|
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: bubbleUpEmojiOrStickersets), uniqueId: item.uniqueId, isFile: true))
|
||||||
case let .asset(asset):
|
case let .asset(asset):
|
||||||
var randomId: Int64 = 0
|
var randomId: Int64 = 0
|
||||||
arc4random_buf(&randomId, 8)
|
arc4random_buf(&randomId, 8)
|
||||||
@ -529,8 +590,29 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
|
|||||||
if !entities.isEmpty {
|
if !entities.isEmpty {
|
||||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||||
|
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||||
|
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||||
|
if let file = value.file {
|
||||||
|
if let packId = value.interactivelySelectedFromPackId {
|
||||||
|
bubbleUpEmojiOrStickersetsById[file.fileId.id] = packId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||||
|
for entity in entities {
|
||||||
|
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||||
|
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||||
|
if !bubbleUpEmojiOrStickersets.contains(packId) {
|
||||||
|
bubbleUpEmojiOrStickersets.append(packId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: []), uniqueId: item.uniqueId, isFile: true))
|
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: bubbleUpEmojiOrStickersets), uniqueId: item.uniqueId, isFile: true))
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -664,8 +746,29 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
|
|||||||
if !entities.isEmpty {
|
if !entities.isEmpty {
|
||||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||||
|
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||||
|
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||||
|
if let file = value.file {
|
||||||
|
if let packId = value.interactivelySelectedFromPackId {
|
||||||
|
bubbleUpEmojiOrStickersetsById[file.fileId.id] = packId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||||
|
for entity in entities {
|
||||||
|
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||||
|
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||||
|
if !bubbleUpEmojiOrStickersets.contains(packId) {
|
||||||
|
bubbleUpEmojiOrStickersets.append(packId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: []), uniqueId: item.uniqueId, isFile: asFile))
|
messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text.string, attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil, bubbleUpEmojiOrStickersets: bubbleUpEmojiOrStickersets), uniqueId: item.uniqueId, isFile: asFile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3694,8 +3694,9 @@ func replayFinalState(
|
|||||||
}
|
}
|
||||||
var updatedInfos: [StickerPackCollectionInfo] = []
|
var updatedInfos: [StickerPackCollectionInfo] = []
|
||||||
for id in ids {
|
for id in ids {
|
||||||
let currentInfo = currentDict[ItemCollectionId(namespace: collectionNamespace, id: id)]!
|
if let currentInfo = currentDict[ItemCollectionId(namespace: collectionNamespace, id: id)] {
|
||||||
updatedInfos.append(currentInfo)
|
updatedInfos.append(currentInfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for info in currentInfos {
|
for info in currentInfos {
|
||||||
if !updatedInfos.contains(where: { $0.id == info.id }) {
|
if !updatedInfos.contains(where: { $0.id == info.id }) {
|
||||||
|
@ -17031,15 +17031,28 @@ enum AllowedReactions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func peerMessageAllowedReactions(context: AccountContext, message: Message) -> Signal<AllowedReactions?, NoError> {
|
func peerMessageAllowedReactions(context: AccountContext, message: Message) -> Signal<AllowedReactions?, NoError> {
|
||||||
return context.engine.data.get(
|
return combineLatest(
|
||||||
TelegramEngine.EngineData.Item.Peer.Peer(id: message.id.peerId),
|
context.engine.data.get(
|
||||||
TelegramEngine.EngineData.Item.Peer.AllowedReactions(id: message.id.peerId)
|
TelegramEngine.EngineData.Item.Peer.Peer(id: message.id.peerId),
|
||||||
|
TelegramEngine.EngineData.Item.Peer.AllowedReactions(id: message.id.peerId)
|
||||||
|
),
|
||||||
|
context.engine.stickers.availableReactions() |> take(1)
|
||||||
)
|
)
|
||||||
|> map { peer, allowedReactions -> AllowedReactions? in
|
|> map { data, availableReactions -> AllowedReactions? in
|
||||||
|
let (peer, allowedReactions) = data
|
||||||
|
|
||||||
if let effectiveReactions = message.effectiveReactions, effectiveReactions.count >= 11 {
|
if let effectiveReactions = message.effectiveReactions, effectiveReactions.count >= 11 {
|
||||||
return .set(Set(effectiveReactions.map(\.value)))
|
return .set(Set(effectiveReactions.map(\.value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||||
|
if let availableReactions = availableReactions {
|
||||||
|
return .set(Set(availableReactions.reactions.map(\.value)))
|
||||||
|
} else {
|
||||||
|
return .set(Set())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch allowedReactions {
|
switch allowedReactions {
|
||||||
case .unknown:
|
case .unknown:
|
||||||
return .all
|
return .all
|
||||||
|
Loading…
x
Reference in New Issue
Block a user