From a70d2d70ae8975af5b00f93ae596589b42017c38 Mon Sep 17 00:00:00 2001 From: Maxime Ollivier Date: Fri, 26 Jun 2020 10:03:47 -0700 Subject: [PATCH] fix update queueing when using reload fallback Summary: If we fallback to `reloadData`, we don't queue the next update. That means if you call `performUpdate` multiple times quickly, there's a chance that the last update doesn't take effect. Reviewed By: Haud Differential Revision: D22219237 fbshipit-source-id: 167e3428859a0194f8f8c57624504edd531480df --- CHANGELOG.md | 2 ++ Source/IGListKit/IGListAdapterUpdater.m | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8893e493..8da30863b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag - Fixed `IGListAdapterUpdaterDelegate` by 1) calling `willReloadDataWithCollectionView` on fallback reloads and 2) making sure `willPerformBatchUpdatesWithCollectionView` is only called when performing a batch update. [Maxime Ollivier](https://github.com/maxolls) (tbd) +- Fixed missing update when calling `performUpdatesAnimated` multiple times quickly and using the `reloadDataFallback()`. [Maxime Ollivier](https://github.com/maxolls) (tbd) + 4.0.0 ----- ### Breaking Changes diff --git a/Source/IGListKit/IGListAdapterUpdater.m b/Source/IGListKit/IGListAdapterUpdater.m index dd0511bde..721f5a14a 100644 --- a/Source/IGListKit/IGListAdapterUpdater.m +++ b/Source/IGListKit/IGListAdapterUpdater.m @@ -179,6 +179,10 @@ - (void)performBatchUpdatesWithCollectionViewBlock:(IGListCollectionViewBlock)co [collectionView layoutIfNeeded]; executeCompletionBlocks(YES); [delegate listAdapterUpdater:self didReloadDataWithCollectionView:collectionView isFallbackReload:YES]; + + // queue another update in case something changed during batch updates. this method will bail next runloop if + // there are no changes + [self _queueUpdateWithCollectionViewBlock:collectionViewBlock]; }; // disables multiple performBatchUpdates: from happening at the same time