Commit 9be7f8d8 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[CRD iOS] Auto-refreshing host list

Previously we never refresh the host list after it gets loaded, which
increases the host-offline error by a lot. This CL fixes this by
triggering host list refresh when the app is brought back from
background (applicationDidBecomeActive:) and when the user is
disconnected from the session (viewWillAppear:).

Bug: 830849
Change-Id: Iddbef200cd894bbe60c2a1b42330a186eda80c76
Reviewed-on: https://chromium-review.googlesource.com/1003141Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550262}
parent 5b010307
......@@ -219,8 +219,24 @@ using remoting::HostListService;
[super viewWillAppear:animated];
// Just in case the view controller misses the host list state event before
// gthe listener is registered.
// the listener is registered.
[self refreshContent];
_hostListService->RequestFetch();
[NSNotificationCenter.defaultCenter
addObserver:self
selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[NSNotificationCenter.defaultCenter
removeObserver:self
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
......@@ -329,7 +345,11 @@ animationControllerForDismissedController:(UIViewController*)dismissed {
- (void)refreshContent {
if (_hostListService->state() == HostListService::State::FETCHING) {
if (![self isAnyRefreshControlRefreshing]) {
// We don't need to show the fetching view when host list is being fetched
// while the previous host list is already on screen. Refresh control will
// handle the user-triggered refresh, and we don't need to show anything if
// that's a background refresh (e.g. user just closed the session).
if (self.contentViewController != _collectionViewController) {
self.contentViewController = _fetchingViewController;
}
return;
......@@ -406,4 +426,8 @@ animationControllerForDismissedController:(UIViewController*)dismissed {
}
}
- (void)applicationDidBecomeActive:(UIApplication*)application {
_hostListService->RequestFetch();
}
@end
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