ListView: fix snapToBounds animation when preserving the current offset

CachedPeerDataTable: don't remove cached data from the cache
This commit is contained in:
Peter 2019-06-18 14:10:15 +01:00
parent 125835872a
commit ea8cbbd7bc
3 changed files with 18 additions and 16 deletions

View File

@ -759,7 +759,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
return additionalInverseTopInset
}
private func snapToBounds(snapTopItem: Bool, stackFromBottom: Bool, updateSizeAndInsets: ListViewUpdateSizeAndInsets? = nil, scrollToItem: ListViewScrollToItem? = nil) -> (snappedTopInset: CGFloat, offset: CGFloat) {
private func snapToBounds(snapTopItem: Bool, stackFromBottom: Bool, updateSizeAndInsets: ListViewUpdateSizeAndInsets? = nil, scrollToItem: ListViewScrollToItem? = nil, isExperimentalSnapToScrollToItem: Bool = false) -> (snappedTopInset: CGFloat, offset: CGFloat) {
if self.itemNodes.count == 0 {
return (0.0, 0.0)
}
@ -819,7 +819,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
var transition: ContainedViewLayoutTransition = .immediate
if let updateSizeAndInsets = updateSizeAndInsets {
if !updateSizeAndInsets.duration.isZero {
if !updateSizeAndInsets.duration.isZero && !isExperimentalSnapToScrollToItem {
switch updateSizeAndInsets.curve {
case let .Spring(duration):
transition = .animated(duration: duration, curve: .spring)
@ -828,6 +828,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
}
} else if let scrollToItem = scrollToItem {
if scrollToItem.animated {
switch scrollToItem.curve {
case let .Spring(duration):
transition = .animated(duration: duration, curve: .spring)
@ -839,6 +840,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
}
}
}
var offset: CGFloat = 0.0
if topItemFound && bottomItemFound {
@ -2484,7 +2486,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
itemNode.position = CGPoint(x: position.x, y: position.y + offsetFix)
}
let (snappedTopInset, snapToBoundsOffset) = self.snapToBounds(snapTopItem: scrollToItem != nil, stackFromBottom: self.stackFromBottom, updateSizeAndInsets: updateSizeAndInsets)
let (snappedTopInset, snapToBoundsOffset) = self.snapToBounds(snapTopItem: scrollToItem != nil, stackFromBottom: self.stackFromBottom, updateSizeAndInsets: updateSizeAndInsets, isExperimentalSnapToScrollToItem: isExperimentalSnapToScrollToItem)
if !snappedTopInset.isZero && (previousVisibleSize.height.isZero || previousApparentFrames.isEmpty) {
offsetFix += snappedTopInset
@ -2504,7 +2506,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
sizeAndInsetsOffset = offsetFix
completeOffset += snapToBoundsOffset
if !updateSizeAndInsets.duration.isZero {
if !updateSizeAndInsets.duration.isZero && !isExperimentalSnapToScrollToItem {
let animation: CABasicAnimation
switch updateSizeAndInsets.curve {
case let .Spring(duration):

View File

@ -54,6 +54,5 @@ final class CachedPeerDataTable: Table {
}
self.updatedPeerIds.removeAll()
self.cachedDatas.removeAll()
}
}

View File

@ -143,7 +143,6 @@ private final class HistoryPreloadViewContext {
private enum ChatHistoryPreloadEntity: Hashable {
case peer(PeerId)
//case group(PeerGroupId)
}
private struct ChatHistoryPreloadIndex {
@ -317,7 +316,9 @@ final class ChatHistoryPreloadManager {
return
}
#if DEBUG
//return;
if true {
//return
}
#endif
var indices: [(ChatHistoryPreloadIndex, Bool, Bool)] = []
for entry in view.0.entries {