mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix story reactions
This commit is contained in:
parent
8d18ce3f5c
commit
3cb9b21c72
@ -1965,18 +1965,14 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedReaction: AvailableReactions.Reaction?
|
var animation: TelegramMediaFile?
|
||||||
for reaction in availableReactions.reactions {
|
for reaction in availableReactions.reactions {
|
||||||
if reaction.value == updateReaction.reaction {
|
if reaction.value == updateReaction.reaction {
|
||||||
selectedReaction = reaction
|
animation = reaction.centerAnimation
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let reaction = selectedReaction else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let targetView = UIView(frame: CGRect(origin: CGPoint(x: floor((self.bounds.width - 100.0) * 0.5), y: floor((self.bounds.height - 100.0) * 0.5)), size: CGSize(width: 100.0, height: 100.0)))
|
let targetView = UIView(frame: CGRect(origin: CGPoint(x: floor((self.bounds.width - 100.0) * 0.5), y: floor((self.bounds.height - 100.0) * 0.5)), size: CGSize(width: 100.0, height: 100.0)))
|
||||||
targetView.isUserInteractionEnabled = false
|
targetView.isUserInteractionEnabled = false
|
||||||
self.addSubview(targetView)
|
self.addSubview(targetView)
|
||||||
@ -1997,71 +1993,70 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
if hasFirstResponder(self) {
|
if hasFirstResponder(self) {
|
||||||
self.endEditing(true)
|
self.endEditing(true)
|
||||||
}
|
}
|
||||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut)))
|
self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut)))
|
||||||
|
|
||||||
if let centerAnimation = reaction.centerAnimation {
|
var text = ""
|
||||||
let file = centerAnimation
|
var messageAttributes: [MessageAttribute] = []
|
||||||
|
var inlineStickers: [MediaId : Media] = [:]
|
||||||
var text = ""
|
switch updateReaction {
|
||||||
var messageAttributes: [MessageAttribute] = []
|
case let .builtin(textValue):
|
||||||
var inlineStickers: [MediaId : Media] = [:]
|
text = textValue
|
||||||
switch reaction.value {
|
case let .custom(fileId, file):
|
||||||
case let .builtin(textValue):
|
if let file {
|
||||||
text = textValue
|
animation = file
|
||||||
case .custom:
|
|
||||||
loop: for attribute in file.attributes {
|
loop: for attribute in file.attributes {
|
||||||
switch attribute {
|
switch attribute {
|
||||||
case let .CustomEmoji(_, _, displayText, _):
|
case let .CustomEmoji(_, _, displayText, _):
|
||||||
text = displayText
|
text = displayText
|
||||||
messageAttributes = [
|
let length = (text as NSString).length
|
||||||
TextEntitiesMessageAttribute(entities: [MessageTextEntity(range: 0 ..< 1, type: .CustomEmoji(stickerPack: nil, fileId: centerAnimation.fileId.id))])
|
messageAttributes = [TextEntitiesMessageAttribute(entities: [MessageTextEntity(range: 0 ..< length, type: .CustomEmoji(stickerPack: nil, fileId: fileId))])]
|
||||||
]
|
inlineStickers = [file.fileId: file]
|
||||||
inlineStickers = [centerAnimation.fileId: centerAnimation]
|
|
||||||
break loop
|
break loop
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let message: EnqueueMessage = .message(
|
let message: EnqueueMessage = .message(
|
||||||
text: text,
|
text: text,
|
||||||
attributes: messageAttributes,
|
attributes: messageAttributes,
|
||||||
inlineStickers: inlineStickers,
|
inlineStickers: inlineStickers,
|
||||||
mediaReference: nil,
|
mediaReference: nil,
|
||||||
replyToMessageId: nil,
|
replyToMessageId: nil,
|
||||||
replyToStoryId: StoryId(peerId: component.slice.peer.id, id: component.slice.item.storyItem.id),
|
replyToStoryId: StoryId(peerId: component.slice.peer.id, id: component.slice.item.storyItem.id),
|
||||||
localGroupingKey: nil,
|
localGroupingKey: nil,
|
||||||
correlationId: nil,
|
correlationId: nil,
|
||||||
bubbleUpEmojiOrStickersets: []
|
bubbleUpEmojiOrStickersets: []
|
||||||
)
|
)
|
||||||
|
|
||||||
let context = component.context
|
let context = component.context
|
||||||
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme)
|
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme)
|
||||||
let presentController = component.presentController
|
let presentController = component.presentController
|
||||||
let controller = component.controller
|
let peer = component.slice.peer
|
||||||
let peer = component.slice.peer
|
|
||||||
|
let _ = (enqueueMessages(account: context.account, peerId: peer.id, messages: [message])
|
||||||
let _ = (enqueueMessages(account: context.account, peerId: peer.id, messages: [message])
|
|> deliverOnMainQueue).start(next: { [weak self] messageIds in
|
||||||
|> deliverOnMainQueue).start(next: { messageIds in
|
if let animation {
|
||||||
presentController(UndoOverlayController(
|
presentController(UndoOverlayController(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
content: .sticker(context: context, file: centerAnimation, loop: false, title: nil, text: "Reaction Sent.", undoText: "View in Chat", customAction: {
|
content: .sticker(context: context, file: animation, loop: false, title: nil, text: "Reaction Sent.", undoText: "View in Chat", customAction: { [weak self] in
|
||||||
if let messageId = messageIds.first, let messageId, let navigationController = controller()?.navigationController as? NavigationController {
|
if let messageId = messageIds.first, let self {
|
||||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peer), subject: .message(id: .id(messageId), highlight: false, timecode: nil)))
|
self.navigateToPeer(peer: peer, messageId: messageId)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
elevatedLayout: false,
|
elevatedLayout: false,
|
||||||
animateInAsReplacement: false,
|
animateInAsReplacement: false,
|
||||||
action: { _ in return false }
|
action: { _ in return false }
|
||||||
), nil)
|
), nil)
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2236,7 +2231,7 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private func navigateToPeer(peer: EnginePeer) {
|
private func navigateToPeer(peer: EnginePeer, messageId: EngineMessage.Id? = nil) {
|
||||||
guard let component = self.component else {
|
guard let component = self.component else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2247,7 +2242,7 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
component.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: component.context, chatLocation: .peer(peer), keepStack: .always, animated: true, pushController: { [weak controller, weak navigationController] chatController, animated, completion in
|
component.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: component.context, chatLocation: .peer(peer), subject: messageId.flatMap { .message(id: .id($0), highlight: false, timecode: nil) }, keepStack: .always, animated: true, pushController: { [weak controller, weak navigationController] chatController, animated, completion in
|
||||||
guard let controller, let navigationController else {
|
guard let controller, let navigationController else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user