From 0fef406f8c0d0d90cdcaaa33e8c38b21d48eea91 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 21 Mar 2019 19:27:30 +0400 Subject: [PATCH] Fixed volume button to unmute action for round videos Fixed video unmute tooltip --- TelegramUI/ChatController.swift | 4 ++-- TelegramUI/ChatControllerNode.swift | 10 ++++++---- .../ChatMessageInteractiveInstantVideoNode.swift | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/TelegramUI/ChatController.swift b/TelegramUI/ChatController.swift index 9c2ac705e7..4731a447e2 100644 --- a/TelegramUI/ChatController.swift +++ b/TelegramUI/ChatController.swift @@ -3265,8 +3265,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal } } - let shouldBeActive = combineLatest(MediaManager.globalAudioSession.isPlaybackActive(), self.chatDisplayNode.historyNode.hasVisiblePlayableItemNodes) - |> deliverOnMainQueue + let shouldBeActive = combineLatest(MediaManager.globalAudioSession.isPlaybackActive() |> deliverOnMainQueue, self.chatDisplayNode.historyNode.hasVisiblePlayableItemNodes) |> mapToSignal { [weak self] isPlaybackActive, hasVisiblePlayableItemNodes -> Signal in if hasVisiblePlayableItemNodes && !isPlaybackActive { return Signal { [weak self] subscriber in @@ -3287,6 +3286,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal guard let strongSelf = self, strongSelf.traceVisibility() && isTopmostChatController(strongSelf) else { return } + strongSelf.videoUnmuteTooltipController?.dismiss() strongSelf.chatDisplayNode.playFirstMediaWithSound() }) diff --git a/TelegramUI/ChatControllerNode.swift b/TelegramUI/ChatControllerNode.swift index c292188051..8a909823de 100644 --- a/TelegramUI/ChatControllerNode.swift +++ b/TelegramUI/ChatControllerNode.swift @@ -1493,14 +1493,16 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { var hasUnconsumed = false self.historyNode.forEachVisibleItemNode { itemNode in if let itemNode = itemNode as? ChatMessageItemView, let (action, _, _, isUnconsumed, _) = itemNode.playMediaWithSound() { - if case let .visible(fraction) = itemNode.visibility { - hasUnconsumed = isUnconsumed + if case let .visible(fraction) = itemNode.visibility, fraction > 0.7 { actions.insert((fraction, isUnconsumed, action), at: 0) + if !hasUnconsumed && isUnconsumed { + hasUnconsumed = true + } } } } - for (fraction, isUnconsumed, action) in actions { - if fraction > 0.7 && (!hasUnconsumed || isUnconsumed) { + for (_, isUnconsumed, action) in actions { + if (!hasUnconsumed || isUnconsumed) { action() break } diff --git a/TelegramUI/ChatMessageInteractiveInstantVideoNode.swift b/TelegramUI/ChatMessageInteractiveInstantVideoNode.swift index 97e67fc354..53ef848cfa 100644 --- a/TelegramUI/ChatMessageInteractiveInstantVideoNode.swift +++ b/TelegramUI/ChatMessageInteractiveInstantVideoNode.swift @@ -751,11 +751,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { func playMediaWithSound() -> (action: () -> Void, soundEnabled: Bool, isVideoMessage: Bool, isUnread: Bool, badgeNode: ASDisplayNode?)? { if let item = self.item { - var notConsumed = false + var isUnconsumed = false for attribute in item.message.attributes { if let attribute = attribute as? ConsumableContentMessageAttribute { if !attribute.consumed { - notConsumed = true + isUnconsumed = true } break } @@ -782,7 +782,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { } }) } - }, false, true, !notConsumed, nil) + }, false, true, isUnconsumed, nil) } else { return nil }