From 0e2db06bdda0edfca29eed201dfa97b0568ffec2 Mon Sep 17 00:00:00 2001 From: Maxime Ollivier Date: Tue, 6 Aug 2024 11:37:51 -0700 Subject: [PATCH] fix coalesce interval Summary: The delay should be using the `_coalescenceInterval` before it gets updated by `intervalIncrement` Differential Revision: D60834604 fbshipit-source-id: 1bf18725a302843c12b50711f0628493c4a04e61 --- Source/IGListKit/Internal/IGListUpdateCoalescer.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/IGListKit/Internal/IGListUpdateCoalescer.m b/Source/IGListKit/Internal/IGListUpdateCoalescer.m index af8b894eb..361698f20 100644 --- a/Source/IGListKit/Internal/IGListUpdateCoalescer.m +++ b/Source/IGListKit/Internal/IGListUpdateCoalescer.m @@ -57,21 +57,22 @@ - (void)_adaptiveDispatchUpdateForView:(nullable UIView *)view { const IGListAdaptiveCoalescingExperimentConfig config = _adaptiveCoalescingExperimentConfig; const NSTimeInterval timeSinceLastUpdate = -[_lastUpdateStartDate timeIntervalSinceNow]; const BOOL isViewVisible = _isViewVisible(view, config); + const NSTimeInterval currentCoalescenceInterval = _coalescenceInterval; if (isViewVisible) { - if (!_lastUpdateStartDate || timeSinceLastUpdate > _coalescenceInterval) { + if (!_lastUpdateStartDate || timeSinceLastUpdate > currentCoalescenceInterval) { // It's been long enough, so lets reset interval and perform update right away _coalescenceInterval = config.minInterval; [self _performUpdate]; return; } else { // If we keep hitting the delay, lets increase it. - _coalescenceInterval = MIN(_coalescenceInterval + config.intervalIncrement, config.maxInterval); + _coalescenceInterval = MIN(currentCoalescenceInterval + config.intervalIncrement, config.maxInterval); } } // Delay by the time remaining in the interval - const NSTimeInterval remainingTime = isViewVisible ? (_coalescenceInterval - timeSinceLastUpdate) : config.maxInterval; + const NSTimeInterval remainingTime = isViewVisible ? (currentCoalescenceInterval - timeSinceLastUpdate) : config.maxInterval; const NSTimeInterval remainingTimeCapped = MAX(remainingTime, 0); _hasQueuedUpdate = YES;