Commit 30ad7b23 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Fixes feed refresh after FeedVC was replaced.

When setting a new DiscoverFeedVC calling reloadData would sometimes
not actually reload the Feed. Taking a look at a similar method
I realized that there's a bug and workaround for that, which I added to
our DiscoverFeedVC setter

Here's where the workaround is also being used:
https://source.chromium.org/chromium/chromium/src/+/master:ios/chrome/browser/ui/content_suggestions/content_suggestions_mediator.mm;l=504

Bug: 1085419
Change-Id: I9cf39edfe9da9006dc0b26bf1b27bb0f8c41d255
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355439Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798625}
parent eb436ad4
......@@ -775,7 +775,16 @@ const NSInteger kMaxNumMostVisitedTiles = 4;
DCHECK(_discoverFeed != discoverFeed);
_discoverFeed = discoverFeed;
_discoverItem.discoverFeed = _discoverFeed;
[self.dataSink reloadAllData];
// The UICollectionView -reloadData method is a no-op if it is called at the
// same time as other collection updates. This full refresh command can come
// at the same time as other collection update commands. To make sure that it
// is taken into account, dispatch it with a delay. See
// http://crbug.com/945726.
dispatch_after(
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
[self reloadAllData];
});
}
#pragma mark - PrefObserverDelegate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment