Index: remoting/ios/app/remoting_view_controller.mm |
diff --git a/remoting/ios/app/remoting_view_controller.mm b/remoting/ios/app/remoting_view_controller.mm |
index 5d560a1b1fc8249661db30959a24c5c78992fb57..a5b46c5acbcaa5a1156f52194abedc2833fc36b3 100644 |
--- a/remoting/ios/app/remoting_view_controller.mm |
+++ b/remoting/ios/app/remoting_view_controller.mm |
@@ -32,7 +32,8 @@ static CGFloat kHostInset = 5.f; |
@interface RemotingViewController ()<HostCollectionViewControllerDelegate, |
UIViewControllerAnimatedTransitioning, |
UIViewControllerTransitioningDelegate> { |
- bool _isAuthenticated; |
+ BOOL _isAuthenticated; |
+ BOOL _showAccountSignIn; |
Yuwei
2017/07/06 22:29:45
Maybe change this to _showSignedInAccount? _showAc
nicholss
2017/07/06 22:40:01
sounds fine. Done.
|
MDCDialogTransitionController* _dialogTransitionController; |
MDCAppBar* _appBar; |
HostCollectionViewController* _collectionViewController; |
@@ -48,6 +49,7 @@ static CGFloat kHostInset = 5.f; |
- (instancetype)init { |
_isAuthenticated = NO; |
+ _showAccountSignIn = YES; |
UICollectionViewFlowLayout* layout = |
[[MDCCollectionViewFlowLayout alloc] init]; |
layout.minimumInteritemSpacing = 0; |
@@ -126,16 +128,9 @@ static CGFloat kHostInset = 5.f; |
object:nil]; |
} |
-- (void)viewWillAppear:(BOOL)animated { |
- [super viewWillAppear:animated]; |
- |
- [self nowAuthenticated:_remotingService.authentication.user.isAuthenticated]; |
- [self presentStatus]; |
-} |
- |
- (void)viewDidAppear:(BOOL)animated { |
[super viewDidAppear:animated]; |
- if (!_isAuthenticated) { |
+ if (!_remotingService.authentication.user.isAuthenticated) { |
[AppDelegate.instance presentSignInFlow]; |
MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; |
message.text = @"Please login."; |
@@ -156,22 +151,24 @@ static CGFloat kHostInset = 5.f; |
} |
- (void)userDidUpdateNotification:(NSNotification*)notification { |
- [self nowAuthenticated:_remotingService.authentication.user.isAuthenticated]; |
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{ |
+ [self |
+ nowAuthenticated:_remotingService.authentication.user.isAuthenticated]; |
+ }]; |
} |
#pragma mark - RemotingAuthenticationDelegate |
- (void)nowAuthenticated:(BOOL)authenticated { |
+ _isAuthenticated = authenticated; |
if (authenticated) { |
- MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; |
- message.text = @"Logged In!"; |
- [MDCSnackbarManager showMessage:message]; |
+ _showAccountSignIn = YES; |
+ [self presentStatus]; |
} else { |
MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; |
Yuwei
2017/07/06 22:29:45
If we already presentSignInFlow if the user hasn't
nicholss
2017/07/06 22:40:01
Acknowledged.
|
- message.text = @"Not logged in."; |
+ message.text = @"Please sign-in."; |
[MDCSnackbarManager showMessage:message]; |
} |
- _isAuthenticated = authenticated; |
[_collectionViewController.collectionView reloadData]; |
} |
@@ -254,7 +251,8 @@ animationControllerForDismissedController:(UIViewController*)dismissed { |
- (void)presentStatus { |
MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; |
- if (_isAuthenticated) { |
+ if (_isAuthenticated && _showAccountSignIn) { |
Yuwei
2017/07/06 22:29:45
I think we still want to show the message if the u
nicholss
2017/07/06 22:40:01
I think that sounds like a good refactor, pull all
|
+ _showAccountSignIn = NO; |
message.text = [NSString |
stringWithFormat:@"Currently signed in as %@.", |
_remotingService.authentication.user.userEmail]; |