From 19d984dc8f45d6745105c55951ff532dc9cb7f9b Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 28 Jan 2023 17:10:58 +0400 Subject: [PATCH] Various fixes --- .../Sources/PremiumIntroScreen.swift | 6 +---- .../Sources/ChatHistoryListNode.swift | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index b17f5847cf..eac07cf23e 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -2094,11 +2094,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent { strongSelf.otherPeerName = otherPeerName if !hadProducts { - if let _ = products.first(where: { $0.isCurrent }) { - strongSelf.selectedProductId = strongSelf.products?.first?.id - } else { - strongSelf.selectedProductId = strongSelf.products?.last?.id - } + strongSelf.selectedProductId = strongSelf.products?.first?.id for (_, video) in promoConfiguration.videos { strongSelf.preloadDisposableSet.add(preloadVideoResource(postbox: context.account.postbox, userLocation: .other, userContentType: .video, resourceReference: .standalone(resource: video.resource), duration: 3.0).start()) diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 7ccefebcac..21cdc14737 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -1397,14 +1397,29 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { scrollAnimationCurve = .Spring(duration: 0.4) } else { let wasPlaying = strongSelf.appliedPlayingMessageId != nil - if strongSelf.appliedPlayingMessageId != currentlyPlayingMessageId, let (currentlyPlayingMessageId, currentlyPlayingVideo) = currentlyPlayingMessageIdAndType { if isFirstTime { } else if case let .peer(peerId) = chatLocation, currentlyPlayingMessageId.id.peerId != peerId { } else { - if wasPlaying || currentlyPlayingVideo { - updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Up, animated: true, highlight: true, displayLink: true) - scrollAnimationCurve = .Spring(duration: 0.4) + var isChat = false + if case .peer = chatLocation { + isChat = true + } + + if (isChat && (wasPlaying || currentlyPlayingVideo)) || (!isChat && !wasPlaying && currentlyPlayingVideo) { + var currentIsVisible = true + if let appliedPlayingMessageId = strongSelf.appliedPlayingMessageId { + currentIsVisible = false + strongSelf.forEachVisibleMessageItemNode({ view in + if view.item?.message.id == appliedPlayingMessageId.id { + currentIsVisible = true + } + }) + } + if currentIsVisible { + updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Up, animated: true, highlight: true, displayLink: true) + scrollAnimationCurve = .Spring(duration: 0.4) + } } } }