Fix a number of tag loading glitches

This commit is contained in:
Isaac 2024-01-29 23:56:04 +01:00
parent e1e1abf4b1
commit 4ffc6367bb
6 changed files with 72 additions and 5 deletions

View File

@ -2082,7 +2082,7 @@ enum HistoryViewState {
init(postbox: PostboxImpl, inputAnchor: HistoryViewInputAnchor, tag: HistoryViewInputTag?, appendMessagesFromTheSameGroup: Bool, namespaces: MessageIdNamespaces, statistics: MessageHistoryViewOrderStatistics, ignoreMessagesInTimestampRange: ClosedRange<Int32>?, halfLimit: Int, locations: MessageHistoryViewInput) { init(postbox: PostboxImpl, inputAnchor: HistoryViewInputAnchor, tag: HistoryViewInputTag?, appendMessagesFromTheSameGroup: Bool, namespaces: MessageIdNamespaces, statistics: MessageHistoryViewOrderStatistics, ignoreMessagesInTimestampRange: ClosedRange<Int32>?, halfLimit: Int, locations: MessageHistoryViewInput) {
switch inputAnchor { switch inputAnchor {
case let .index(index): case let .index(index):
self = .loaded(HistoryViewLoadedState(anchor: .index(index), tag: tag, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, namespaces: namespaces, statistics: statistics, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, halfLimit: halfLimit, locations: locations, postbox: postbox, holes: HistoryViewHoles(holesBySpace: fetchHoles(postbox: postbox, locations: locations, tag: tag, namespaces: namespaces)))) self = .loaded(HistoryViewLoadedState(anchor: .index(index), tag: tag, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, namespaces: namespaces, statistics: statistics, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, halfLimit: halfLimit, locations: locations, postbox: postbox, holes: HistoryViewHoles(holesBySpace: fetchHoles(postbox: postbox, locations: locations, tag: tag, namespaces: namespaces))))
case .lowerBound: case .lowerBound:
self = .loaded(HistoryViewLoadedState(anchor: .lowerBound, tag: tag, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, namespaces: namespaces, statistics: statistics, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, halfLimit: halfLimit, locations: locations, postbox: postbox, holes: HistoryViewHoles(holesBySpace: fetchHoles(postbox: postbox, locations: locations, tag: tag, namespaces: namespaces)))) self = .loaded(HistoryViewLoadedState(anchor: .lowerBound, tag: tag, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, namespaces: namespaces, statistics: statistics, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, halfLimit: halfLimit, locations: locations, postbox: postbox, holes: HistoryViewHoles(holesBySpace: fetchHoles(postbox: postbox, locations: locations, tag: tag, namespaces: namespaces))))
case .upperBound: case .upperBound:

View File

@ -950,7 +950,15 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
case let .aroundId(aroundId): case let .aroundId(aroundId):
filledRange = min(aroundId.id, messageRange.lowerBound) ... max(aroundId.id, messageRange.upperBound) filledRange = min(aroundId.id, messageRange.lowerBound) ... max(aroundId.id, messageRange.upperBound)
strictFilledIndices = IndexSet(integersIn: Int(min(aroundId.id, messageRange.lowerBound)) ... Int(max(aroundId.id, messageRange.upperBound))) strictFilledIndices = IndexSet(integersIn: Int(min(aroundId.id, messageRange.lowerBound)) ... Int(max(aroundId.id, messageRange.upperBound)))
var shouldFillAround = false
if peerInput.requestThreadId(accountPeerId: accountPeerId) != nil { if peerInput.requestThreadId(accountPeerId: accountPeerId) != nil {
shouldFillAround = true
}
if case .customTag = space {
shouldFillAround = true
}
if shouldFillAround {
if ids.count <= count / 2 - 1 { if ids.count <= count / 2 - 1 {
filledRange = minMaxRange filledRange = minMaxRange
} }

View File

@ -157,8 +157,11 @@ private final class ManagedMessageHistoryHolesContext {
}*/ }*/
for entry in entries { for entry in entries {
if self.completedEntries[entry] != nil { if let previousTimestamp = self.completedEntries[entry] {
continue if previousTimestamp >= CFAbsoluteTimeGetCurrent() - 20.0 {
Logger.shared.log("ManagedMessageHistoryHoles", "Not adding recently finished entry \(entry)")
continue
}
} }
switch entry.hole { switch entry.hole {

View File

@ -2539,7 +2539,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
return return
} }
inlineSearchResultsView.alpha = 1.0 inlineSearchResultsView.alpha = 1.0
inlineSearchResultsView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25) inlineSearchResultsView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
inlineSearchResultsView.animateIn() inlineSearchResultsView.animateIn()
transition.updateSublayerTransformScale(node: self.historyNodeContainer, scale: CGPoint(x: 0.95, y: 0.95)) transition.updateSublayerTransformScale(node: self.historyNodeContainer, scale: CGPoint(x: 0.95, y: 0.95))

View File

@ -5,6 +5,7 @@ import SwiftSignalKit
import Display import Display
import AsyncDisplayKit import AsyncDisplayKit
import TelegramCore import TelegramCore
import Postbox
import TelegramPresentationData import TelegramPresentationData
import TelegramUIPreferences import TelegramUIPreferences
import MediaResources import MediaResources
@ -1560,6 +1561,59 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
} }
initialData = combinedInitialData initialData = combinedInitialData
if resetScrolling, let previousViewValue = previousView.with({ $0 })?.0 {
let filteredEntries: [ChatHistoryEntry] = []
let processedView = ChatHistoryView(originalView: MessageHistoryView(tag: nil, namespaces: .all, entries: [], holeEarlier: false, holeLater: false, isLoading: true), filteredEntries: filteredEntries, associatedData: previousViewValue.associatedData, lastHeaderId: 0, id: previousViewValue.id, locationInput: previousViewValue.locationInput, ignoreMessagesInTimestampRange: nil)
let previousValueAndVersion = previousView.swap((processedView, update.1, selectedMessages, allAdMessages.version))
let previous = previousValueAndVersion?.0
let previousSelectedMessages = previousValueAndVersion?.2
if let previousVersion = previousValueAndVersion?.1 {
assert(update.1 >= previousVersion)
}
var reason: ChatHistoryViewTransitionReason
reason = ChatHistoryViewTransitionReason.InteractiveChanges
let disableAnimations = true
let forceSynchronous = true
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: false, chatLocation: chatLocation, controllerInteraction: controllerInteraction, scrollPosition: nil, scrollAnimationCurve: nil, initialData: initialData?.initialData, keyboardButtonsMessage: nil, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: false, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: false)
var mappedTransition = mappedChatHistoryViewListTransition(context: context, chatLocation: chatLocation, associatedData: previousViewValue.associatedData, controllerInteraction: controllerInteraction, mode: mode, lastHeaderId: 0, animateFromPreviousFilter: resetScrolling, transition: rawTransition)
if disableAnimations {
mappedTransition.options.remove(.AnimateInsertion)
mappedTransition.options.remove(.AnimateAlpha)
mappedTransition.options.remove(.AnimateTopItemPosition)
mappedTransition.options.remove(.RequestItemInsertionAnimations)
}
if forceSynchronous || resetScrolling {
mappedTransition.options.insert(.Synchronous)
}
if resetScrolling {
mappedTransition.options.insert(.AnimateAlpha)
mappedTransition.options.insert(.AnimateFullTransition)
}
if resetScrolling {
resetScrolling = false
}
Queue.mainQueue().async {
guard let strongSelf = self else {
return
}
if strongSelf.appliedPlayingMessageId?.0 != currentlyPlayingMessageIdAndType?.0 {
strongSelf.appliedPlayingMessageId = currentlyPlayingMessageIdAndType
}
if strongSelf.appliedScrollToMessageId != scrollToMessageId {
strongSelf.appliedScrollToMessageId = scrollToMessageId
}
strongSelf.enqueueHistoryViewTransition(mappedTransition)
}
}
Queue.mainQueue().async { Queue.mainQueue().async {
if let strongSelf = self { if let strongSelf = self {
if !strongSelf.didSetInitialData { if !strongSelf.didSetInitialData {

View File

@ -37,6 +37,8 @@ func preloadedChatHistoryViewForLocation(_ location: ChatHistoryLocationInput, c
} }
func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMessagesInTimestampRange: ClosedRange<Int32>?, context: AccountContext, chatLocation: ChatLocation, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, scheduled: Bool, fixedCombinedReadStates: MessageHistoryViewReadState?, tag: HistoryViewInputTag?, appendMessagesFromTheSameGroup: Bool, additionalData: [AdditionalMessageHistoryViewData], orderStatistics: MessageHistoryViewOrderStatistics = []) -> Signal<ChatHistoryViewUpdate, NoError> { func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMessagesInTimestampRange: ClosedRange<Int32>?, context: AccountContext, chatLocation: ChatLocation, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, scheduled: Bool, fixedCombinedReadStates: MessageHistoryViewReadState?, tag: HistoryViewInputTag?, appendMessagesFromTheSameGroup: Bool, additionalData: [AdditionalMessageHistoryViewData], orderStatistics: MessageHistoryViewOrderStatistics = []) -> Signal<ChatHistoryViewUpdate, NoError> {
print("request \(location.content)")
let account = context.account let account = context.account
if scheduled { if scheduled {
var first = true var first = true
@ -93,7 +95,7 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMess
let combinedInitialData = ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData) let combinedInitialData = ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData)
if preloaded { if preloaded {
return .HistoryView(view: view, type: .Generic(type: updateType), scrollPosition: nil, flashIndicators: false, originalScrollPosition: nil, initialData: combinedInitialData, id: location.id) return .HistoryView(view: view, type: .Generic(type: updateType), scrollPosition: nil, flashIndicators: false, originalScrollPosition: nil, initialData: combinedInitialData, id: location.id)
} else { } else {
if view.isLoading { if view.isLoading {