mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API
This commit is contained in:
parent
9f94bc7f83
commit
d5c9ab46a7
@ -182,7 +182,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-651419003] = { return Api.SendMessageAction.parse_speakingInGroupCallAction($0) }
|
||||
dict[-606432698] = { return Api.SendMessageAction.parse_sendMessageHistoryImportAction($0) }
|
||||
dict[-1336228175] = { return Api.SendMessageAction.parse_sendMessageChooseStickerAction($0) }
|
||||
dict[1781674934] = { return Api.SendMessageAction.parse_sendMessageEmojiInteraction($0) }
|
||||
dict[630664139] = { return Api.SendMessageAction.parse_sendMessageEmojiInteraction($0) }
|
||||
dict[-1234857938] = { return Api.SendMessageAction.parse_sendMessageEmojiInteractionSeen($0) }
|
||||
dict[-1137792208] = { return Api.PrivacyKey.parse_privacyKeyStatusTimestamp($0) }
|
||||
dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) }
|
||||
|
@ -4278,7 +4278,7 @@ public extension Api {
|
||||
case speakingInGroupCallAction
|
||||
case sendMessageHistoryImportAction(progress: Int32)
|
||||
case sendMessageChooseStickerAction
|
||||
case sendMessageEmojiInteraction(emoticon: String, interaction: Api.DataJSON)
|
||||
case sendMessageEmojiInteraction(emoticon: String, msgId: Int32, interaction: Api.DataJSON)
|
||||
case sendMessageEmojiInteractionSeen(emoticon: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
@ -4379,11 +4379,12 @@ public extension Api {
|
||||
}
|
||||
|
||||
break
|
||||
case .sendMessageEmojiInteraction(let emoticon, let interaction):
|
||||
case .sendMessageEmojiInteraction(let emoticon, let msgId, let interaction):
|
||||
if boxed {
|
||||
buffer.appendInt32(1781674934)
|
||||
buffer.appendInt32(630664139)
|
||||
}
|
||||
serializeString(emoticon, buffer: buffer, boxed: false)
|
||||
serializeInt32(msgId, buffer: buffer, boxed: false)
|
||||
interaction.serialize(buffer, true)
|
||||
break
|
||||
case .sendMessageEmojiInteractionSeen(let emoticon):
|
||||
@ -4429,8 +4430,8 @@ public extension Api {
|
||||
return ("sendMessageHistoryImportAction", [("progress", progress)])
|
||||
case .sendMessageChooseStickerAction:
|
||||
return ("sendMessageChooseStickerAction", [])
|
||||
case .sendMessageEmojiInteraction(let emoticon, let interaction):
|
||||
return ("sendMessageEmojiInteraction", [("emoticon", emoticon), ("interaction", interaction)])
|
||||
case .sendMessageEmojiInteraction(let emoticon, let msgId, let interaction):
|
||||
return ("sendMessageEmojiInteraction", [("emoticon", emoticon), ("msgId", msgId), ("interaction", interaction)])
|
||||
case .sendMessageEmojiInteractionSeen(let emoticon):
|
||||
return ("sendMessageEmojiInteractionSeen", [("emoticon", emoticon)])
|
||||
}
|
||||
@ -4535,14 +4536,17 @@ public extension Api {
|
||||
public static func parse_sendMessageEmojiInteraction(_ reader: BufferReader) -> SendMessageAction? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: Api.DataJSON?
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
_3 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.SendMessageAction.sendMessageEmojiInteraction(emoticon: _1!, interaction: _2!)
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.SendMessageAction.sendMessageEmojiInteraction(emoticon: _1!, msgId: _2!, interaction: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -1254,7 +1254,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), timestamp: maxDate, actionTimestamp: date)
|
||||
case let .updateUserTyping(userId, type):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
let activity = PeerInputActivity(apiType: type, timestamp: date)
|
||||
let activity = PeerInputActivity(apiType: type, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), timestamp: date)
|
||||
var category: PeerActivitySpace.Category = .global
|
||||
if case .speakingInGroupCall = activity {
|
||||
category = .voiceChat
|
||||
@ -1264,7 +1264,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
case let .updateChatUserTyping(chatId, userId, type):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
let activity = PeerInputActivity(apiType: type, timestamp: date)
|
||||
let activity = PeerInputActivity(apiType: type, peerId: nil, timestamp: date)
|
||||
var category: PeerActivitySpace.Category = .global
|
||||
if case .speakingInGroupCall = activity {
|
||||
category = .voiceChat
|
||||
@ -1277,7 +1277,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
let threadId = topMsgId.flatMap { makeMessageThreadId(MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: $0)) }
|
||||
|
||||
let activity = PeerInputActivity(apiType: type, timestamp: date)
|
||||
let activity = PeerInputActivity(apiType: type, peerId: nil, timestamp: date)
|
||||
var category: PeerActivitySpace.Category = .global
|
||||
if case .speakingInGroupCall = activity {
|
||||
category = .voiceChat
|
||||
|
@ -131,8 +131,8 @@ private func actionFromActivity(_ activity: PeerInputActivity?) -> Api.SendMessa
|
||||
return .speakingInGroupCallAction
|
||||
case .choosingSticker:
|
||||
return .sendMessageChooseStickerAction
|
||||
case let .interactingWithEmoji(emoticon, interaction):
|
||||
return .sendMessageEmojiInteraction(emoticon: emoticon, interaction: interaction?.apiDataJson ?? .dataJSON(data: ""))
|
||||
case let .interactingWithEmoji(emoticon, messageId, interaction):
|
||||
return .sendMessageEmojiInteraction(emoticon: emoticon, msgId: messageId.id, interaction: interaction?.apiDataJson ?? .dataJSON(data: ""))
|
||||
case let .seeingEmojiInteraction(emoticon):
|
||||
return .sendMessageEmojiInteractionSeen(emoticon: emoticon)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
public struct EmojiInteraction: Equatable {
|
||||
@ -66,7 +67,7 @@ public enum PeerInputActivity: Comparable {
|
||||
case uploadingInstantVideo(progress: Int32)
|
||||
case speakingInGroupCall(timestamp: Int32)
|
||||
case choosingSticker
|
||||
case interactingWithEmoji(emoticon: String, interaction: EmojiInteraction?)
|
||||
case interactingWithEmoji(emoticon: String, messageId: MessageId, interaction: EmojiInteraction?)
|
||||
case seeingEmojiInteraction(emoticon: String)
|
||||
|
||||
public var key: Int32 {
|
||||
@ -104,7 +105,7 @@ public enum PeerInputActivity: Comparable {
|
||||
}
|
||||
|
||||
extension PeerInputActivity {
|
||||
init?(apiType: Api.SendMessageAction, timestamp: Int32) {
|
||||
init?(apiType: Api.SendMessageAction, peerId: PeerId?, timestamp: Int32) {
|
||||
switch apiType {
|
||||
case .sendMessageCancelAction, .sendMessageChooseContactAction, .sendMessageGeoLocationAction, .sendMessageRecordVideoAction:
|
||||
return nil
|
||||
@ -130,8 +131,12 @@ extension PeerInputActivity {
|
||||
self = .choosingSticker
|
||||
case .sendMessageHistoryImportAction:
|
||||
return nil
|
||||
case let .sendMessageEmojiInteraction(emoticon, interaction):
|
||||
self = .interactingWithEmoji(emoticon: emoticon, interaction: EmojiInteraction(apiDataJson: interaction))
|
||||
case let .sendMessageEmojiInteraction(emoticon, messageId, interaction):
|
||||
if let peerId = peerId {
|
||||
self = .interactingWithEmoji(emoticon: emoticon, messageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: messageId), interaction: EmojiInteraction(apiDataJson: interaction))
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .sendMessageEmojiInteractionSeen(emoticon):
|
||||
self = .seeingEmojiInteraction(emoticon: emoticon)
|
||||
}
|
||||
|
@ -7430,11 +7430,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.chatTitleView?.inputActivities = (peerId, displayActivities)
|
||||
|
||||
for activity in activities {
|
||||
if case let .interactingWithEmoji(emoticon, maybeInteraction) = activity.1, let interaction = maybeInteraction {
|
||||
if case let .interactingWithEmoji(emoticon, messageId, maybeInteraction) = activity.1, let interaction = maybeInteraction {
|
||||
var found = false
|
||||
strongSelf.chatDisplayNode.historyNode.forEachVisibleItemNode({ itemNode in
|
||||
if !found, let itemNode = itemNode as? ChatMessageAnimatedStickerItemNode, let item = itemNode.item {
|
||||
if item.message.text.strippedEmoji == emoticon {
|
||||
if item.message.id == messageId {
|
||||
for animation in interaction.animations {
|
||||
if animation.timeOffset > 0.0 {
|
||||
Queue.mainQueue().after(Double(animation.timeOffset)) {
|
||||
|
@ -1349,7 +1349,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
animations.append(EmojiInteraction.Animation(index: index, timeOffset: Float(max(0.0, timestamp - startTimestamp))))
|
||||
}
|
||||
|
||||
item.context.account.updateLocalInputActivity(peerId: PeerActivitySpace(peerId: item.message.id.peerId, category: .global), activity: .interactingWithEmoji(emoticon: textEmoji, interaction: EmojiInteraction(animations: animations)), isPresent: true)
|
||||
item.context.account.updateLocalInputActivity(peerId: PeerActivitySpace(peerId: item.message.id.peerId, category: .global), activity: .interactingWithEmoji(emoticon: textEmoji, messageId: item.message.id, interaction: EmojiInteraction(animations: animations)), isPresent: true)
|
||||
}
|
||||
|
||||
func playAdditionalAnimation(index: Int) {
|
||||
@ -1524,7 +1524,11 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
}
|
||||
return .optionalAction({
|
||||
if let animationItems = item.associatedData.additionalAnimatedEmojiStickers[originalTextEmoji] {
|
||||
self.startAdditionalAnimationsCommitTimer()
|
||||
let syncAnimations = item.message.id.peerId.namespace == Namespaces.Peer.CloudUser
|
||||
|
||||
if syncAnimations {
|
||||
self.startAdditionalAnimationsCommitTimer()
|
||||
}
|
||||
|
||||
let timestamp = CACurrentMediaTime()
|
||||
let previousAnimation = self.enqueuedAdditionalAnimations.last
|
||||
@ -1540,15 +1544,19 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
if let index = availableAnimations.randomElement()?.0 {
|
||||
if delay > 0.0 {
|
||||
Queue.mainQueue().after(delay) {
|
||||
self.enqueuedAdditionalAnimations.append((index, timestamp + delay))
|
||||
if syncAnimations {
|
||||
self.enqueuedAdditionalAnimations.append((index, timestamp + delay))
|
||||
}
|
||||
self.playAdditionalAnimation(index: index)
|
||||
|
||||
if self.additionalAnimationsCommitTimer == nil {
|
||||
if syncAnimations, self.additionalAnimationsCommitTimer == nil {
|
||||
self.startAdditionalAnimationsCommitTimer()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.enqueuedAdditionalAnimations.append((index, timestamp))
|
||||
if syncAnimations {
|
||||
self.enqueuedAdditionalAnimations.append((index, timestamp))
|
||||
}
|
||||
self.playAdditionalAnimation(index: index)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user