Various fixes

This commit is contained in:
Ilya Laktyushin
2025-08-25 02:16:37 +04:00
parent 5749548ac8
commit 498ce24a09
7 changed files with 74 additions and 35 deletions

View File

@@ -9,7 +9,7 @@ import ChatControllerInteraction
import ChatHistoryEntry
import ChatMessageBubbleItemNode
func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toView: ChatHistoryView, reason: ChatHistoryViewTransitionReason, reverse: Bool, chatLocation: ChatLocation, controllerInteraction: ChatControllerInteraction, scrollPosition: ChatHistoryViewScrollPosition?, scrollAnimationCurve: ListViewAnimationCurve?, initialData: InitialMessageHistoryData?, keyboardButtonsMessage: Message?, cachedData: CachedPeerData?, cachedDataMessages: [MessageId: Message]?, readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]?, flashIndicators: Bool, updatedMessageSelection: Bool, messageTransitionNode: ChatMessageTransitionNodeImpl?, allUpdated: Bool) -> ChatHistoryViewTransition {
func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toView: ChatHistoryView, reason: ChatHistoryViewTransitionReason, reverse: Bool, chatLocation: ChatLocation, source: ChatHistoryListSource, controllerInteraction: ChatControllerInteraction, scrollPosition: ChatHistoryViewScrollPosition?, scrollAnimationCurve: ListViewAnimationCurve?, initialData: InitialMessageHistoryData?, keyboardButtonsMessage: Message?, cachedData: CachedPeerData?, cachedDataMessages: [MessageId: Message]?, readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]?, flashIndicators: Bool, updatedMessageSelection: Bool, messageTransitionNode: ChatMessageTransitionNodeImpl?, allUpdated: Bool) -> ChatHistoryViewTransition {
var mergeResult: (deleteIndices: [Int], indicesAndItems: [(Int, ChatHistoryEntry, Int?)], updateIndices: [(Int, ChatHistoryEntry, Int)])
let allUpdated = allUpdated || (fromView?.associatedData != toView.associatedData)
if reverse {
@@ -141,6 +141,11 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
let curve: ListViewAnimationCurve = scrollAnimationCurve ?? .Default(duration: nil)
var isSavedMusic = false
if case let .custom(_, _, _, isSavedMusicValue, _, _) = source {
isSavedMusic = isSavedMusicValue
}
if let scrollPosition = scrollPosition {
switch scrollPosition {
case let .unread(unreadIndex):
@@ -238,9 +243,17 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
}
var index = toView.filteredEntries.count - 1
for entry in toView.filteredEntries {
if scrollIndex.index.isLessOrEqual(to: entry.index) {
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
break
if isSavedMusic {
if case let .message(messageIndex) = scrollIndex.index, messageIndex.id == entry.index.id {
print(messageIndex.id)
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
break
}
} else {
if scrollIndex.index.isLessOrEqual(to: entry.index) {
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
break
}
}
index -= 1
}