Commit 968fa93d authored by Felix Paul Kühne's avatar Felix Paul Kühne

cloud services: correctly implement OneDrive session state

parent a53e2d1d
......@@ -54,16 +54,23 @@
}
- (void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(authenticationSessionsChanged:) name:VLCOneDriveControllerSessionUpdated object:nil];
[self.tableView reloadData];
[super viewWillAppear:animated];
}
- (void)goBack
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[[appDelegate revealController] toggleSidebar:![appDelegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
}
- (void)authenticationSessionsChanged:(NSNotification *)notification
{
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
......@@ -136,8 +143,6 @@
return cell;
}
#pragma mark - Table view delegate
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
......
......@@ -13,6 +13,8 @@
#import "VLCOneDriveTableViewController.h"
#import "VLCOneDriveObject.h"
#define VLCOneDriveControllerSessionUpdated @"VLCOneDriveControllerSessionUpdated"
@protocol VLCOneDriveControllerDelegate <NSObject>
@required
......
......@@ -95,20 +95,22 @@
{
APLog(@"OneDrive: authCompleted, status %i, state %@", status, userState);
if (status == 1 && session != NULL && [userState isEqualToString:@"init"])
if (session != NULL && [userState isEqualToString:@"init"] && status == 1)
_activeSession = YES;
else
_activeSession = NO;
if (status == 1 && session != NULL && [userState isEqualToString:@"login"])
if (session != NULL && [userState isEqualToString:@"login"] && status == 1)
_userAuthenticated = YES;
else
if (status == 0) {
_activeSession = NO;
_userAuthenticated = NO;
}
if (self.delegate) {
if ([self.delegate respondsToSelector:@selector(sessionWasUpdated)])
[self.delegate performSelector:@selector(sessionWasUpdated)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:VLCOneDriveControllerSessionUpdated object:self];
}
- (void)authFailed:(NSError *)error userState:(id)userState
......@@ -120,6 +122,7 @@
if ([self.delegate respondsToSelector:@selector(sessionWasUpdated)])
[self.delegate performSelector:@selector(sessionWasUpdated)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:VLCOneDriveControllerSessionUpdated object:self];
}
- (void)liveOperationSucceeded:(LiveDownloadOperation *)operation
......
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