Skip to content

Commit

Permalink
fix coalesce interval
Browse files Browse the repository at this point in the history
Summary: The delay should be using the `_coalescenceInterval` before it gets updated by `intervalIncrement`

Differential Revision: D60834604

fbshipit-source-id: 1bf18725a302843c12b50711f0628493c4a04e61
  • Loading branch information
Maxime Ollivier authored and facebook-github-bot committed Aug 6, 2024
1 parent c1c8f5a commit 0e2db06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Source/IGListKit/Internal/IGListUpdateCoalescer.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0e2db06

Please sign in to comment.