Improve video messages autoscrolling

This commit is contained in:
Ilya Laktyushin 2023-03-09 20:03:55 +04:00
parent 656a0247fc
commit 05c3ae3ae0

View File

@ -1361,6 +1361,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
if (isChat && (wasPlaying || currentlyPlayingVideo)) || (!isChat && !wasPlaying && currentlyPlayingVideo) { if (isChat && (wasPlaying || currentlyPlayingVideo)) || (!isChat && !wasPlaying && currentlyPlayingVideo) {
var currentIsVisible = true var currentIsVisible = true
var nextIsVisible = false
if let appliedPlayingMessageId = strongSelf.appliedPlayingMessageId { if let appliedPlayingMessageId = strongSelf.appliedPlayingMessageId {
currentIsVisible = false currentIsVisible = false
strongSelf.forEachVisibleMessageItemNode({ view in strongSelf.forEachVisibleMessageItemNode({ view in
@ -1369,7 +1370,12 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
} }
}) })
} }
if currentIsVisible && currentlyPlayingVideo { strongSelf.forEachVisibleMessageItemNode({ view in
if view.item?.message.id == currentlyPlayingMessageId.id {
nextIsVisible = true
}
})
if currentIsVisible && nextIsVisible && currentlyPlayingVideo {
updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Up, animated: true, highlight: true, displayLink: true) updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Up, animated: true, highlight: true, displayLink: true)
scrollAnimationCurve = .Spring(duration: 0.4) scrollAnimationCurve = .Spring(duration: 0.4)
} }