diff --git a/submodules/AccountContext/Sources/ChatController.swift b/submodules/AccountContext/Sources/ChatController.swift index ac9c4521d2..764839370a 100644 --- a/submodules/AccountContext/Sources/ChatController.swift +++ b/submodules/AccountContext/Sources/ChatController.swift @@ -560,6 +560,8 @@ public protocol ChatController: ViewController { func beginMessageSearch(_ query: String) func displayPromoAnnouncement(text: String) + func hintPlayNextOutgoingGift() + var isSendButtonVisible: Bool { get } } diff --git a/submodules/PremiumUI/Sources/PremiumGiftScreen.swift b/submodules/PremiumUI/Sources/PremiumGiftScreen.swift index f081acd905..bb59828aab 100644 --- a/submodules/PremiumUI/Sources/PremiumGiftScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumGiftScreen.swift @@ -1311,6 +1311,12 @@ public final class PremiumGiftScreen: ViewControllerComponentContainer { if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController { var controllers = navigationController.viewControllers controllers = controllers.filter { !($0 is PeerInfoScreen) && !($0 is PremiumGiftScreen) } + for controller in controllers.reversed() { + if let chatController = controller as? ChatController, case .peer(id: peerId) = chatController.chatLocation { + chatController.hintPlayNextOutgoingGift() + break + } + } navigationController.setViewControllers(controllers, animated: true) } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index a272a3edce..132c6f37d9 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -16333,6 +16333,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } + public func hintPlayNextOutgoingGift() { + self.controllerInteraction?.playNextOutgoingGift = true + } + private var effectiveNavigationController: NavigationController? { if let navigationController = self.navigationController as? NavigationController { return navigationController diff --git a/submodules/TelegramUI/Sources/ChatControllerInteraction.swift b/submodules/TelegramUI/Sources/ChatControllerInteraction.swift index 2267e19977..75332b03d1 100644 --- a/submodules/TelegramUI/Sources/ChatControllerInteraction.swift +++ b/submodules/TelegramUI/Sources/ChatControllerInteraction.swift @@ -160,6 +160,7 @@ public final class ChatControllerInteraction { var currentMessageWithLoadingReplyThread: MessageId? var updatedPresentationData: (initial: PresentationData, signal: Signal)? let presentationContext: ChatPresentationContext + var playNextOutgoingGift: Bool = false init( openMessage: @escaping (Message, ChatControllerInteractionOpenMessageMode) -> Bool, diff --git a/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift index 6340b68b50..f8240bd04d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageGiftItemNode.swift @@ -41,8 +41,6 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { private var absoluteRect: (CGRect, CGSize)? private var isPlaying: Bool = false - private var wasPending: Bool = false - private var didChangeFromPendingToSent: Bool = false override var visibility: ListViewItemNodeVisibility { didSet { @@ -227,13 +225,7 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { strongSelf.animationNode.setup(source: AnimatedStickerNodeLocalFileSource(name: animationName), width: 384, height: 384, playbackMode: .still(.end), mode: .direct(cachePathPrefix: nil)) } strongSelf.item = item - - if item.message.id.namespace == Namespaces.Message.Local || item.message.id.namespace == Namespaces.Message.ScheduledLocal { - strongSelf.wasPending = true - } - if strongSelf.wasPending && (item.message.id.namespace != Namespaces.Message.Local && item.message.id.namespace != Namespaces.Message.ScheduledLocal) { - strongSelf.didChangeFromPendingToSent = true - } + strongSelf.updateVisibility() strongSelf.backgroundColorNode.backgroundColor = selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) @@ -438,13 +430,21 @@ class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { } } + if !item.message.effectivelyIncoming(item.context.account.peerId) + && item.controllerInteraction.playNextOutgoingGift + && !item.controllerInteraction.seenOneTimeAnimatedMedia.contains(item.message.id) { + alreadySeen = false + } + if !item.controllerInteraction.seenOneTimeAnimatedMedia.contains(item.message.id) { item.controllerInteraction.seenOneTimeAnimatedMedia.insert(item.message.id) self.animationNode.playOnce() } if !alreadySeen { - item.controllerInteraction.animateDiceSuccess(false, true) + Queue.mainQueue().after(1.0) { + item.controllerInteraction.animateDiceSuccess(false, true) + } } } }