From 40800f964d4bb19d52e41abc9881294fbb6a9ebb Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 23 Nov 2022 11:58:52 -0500 Subject: [PATCH] Fix jump to present not scrolling all the way to the top --- Tusker/Screens/Timeline/TimelineViewController.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index ad44ac38..376fab48 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -348,9 +348,13 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro config.action = { [unowned self] toast in toast.dismissToast(animated: true) - self.dataSource.apply(snapshot, animatingDifferences: false) - - self.collectionView.scrollToTop() + self.dataSource.apply(snapshot, animatingDifferences: true) { + // TODO: we can't set prevScrollOffsetBeforeScrollToTop here to allow undoing the scroll-to-top + // because that would involve scrolling through unmeasured-cell which fucks up the content offset values. + // we probably need a data-source aware implementation of scrollToTop which uses item & offset w/in item + // to track the restore position + self.collectionView.scrollToItem(at: IndexPath(row: 0, section: 0), at: .top, animated: true) + } } self.showToast(configuration: config, animated: true) }