From 9ff7c2a33fd1f400023cd58cdc59eaa6894e7d06 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 5 Mar 2021 10:13:42 -0800 Subject: [PATCH] MediaGallery: load later sections if all earlier sections are loaded The collection view loads earlier sections if you're scrolled near the top and later sections if you're scrolled near the bottom. However, if there's only a page of loaded content, you can be near the top /and/ the bottom. Therefore, we need to potentially load later sections even if you're at the top, because you might be at the beginning. --- .../MediaGallery/MediaTileViewController.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Signal/src/ViewControllers/MediaGallery/MediaTileViewController.swift b/Signal/src/ViewControllers/MediaGallery/MediaTileViewController.swift index 900df5a81c..f7fa9f8a41 100644 --- a/Signal/src/ViewControllers/MediaGallery/MediaTileViewController.swift +++ b/Signal/src/ViewControllers/MediaGallery/MediaTileViewController.swift @@ -662,21 +662,13 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDe let oldContentHeight = collectionView.contentSize.height let direction: GalleryDirection - if contentOffsetY < kEdgeThreshold { + if contentOffsetY < kEdgeThreshold && !mediaGallery.hasFetchedOldest { // Near the top, load older content - guard !mediaGallery.hasFetchedOldest else { - return - } - mediaTileViewLayout.recordContentSizeBeforeInsertingToTop() direction = .before - } else if oldContentHeight - contentOffsetY < kEdgeThreshold { + } else if oldContentHeight - contentOffsetY < kEdgeThreshold && !mediaGallery.hasFetchedMostRecent { // Near the bottom, load newer content - guard !mediaGallery.hasFetchedMostRecent else { - return - } - direction = .after } else {