mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-24 09:48:21 +00:00
fix coalesce interval
Summary: The delay should be using the `_coalescenceInterval` before it gets updated by `intervalIncrement` Differential Revision: D60834604 fbshipit-source-id: 1bf18725a302843c12b50711f0628493c4a04e61
This commit is contained in:
parent
c1c8f5acae
commit
0e2db06bdd
1 changed files with 4 additions and 3 deletions
|
|
@ -57,21 +57,22 @@ static BOOL _isViewVisible(UIView *_Nullable view, IGListAdaptiveCoalescingExper
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue