Ver código fonte

Cloud Services: Fix Box controller not updating its status

Closes #749
Edgar Fouillet 5 anos atrás
pai
commit
e27f99b011

+ 18 - 0
Sources/LocalNetworkConnectivity/VLCServerListViewController.m

@@ -39,6 +39,8 @@
 
 #import "VLCWiFiUploadTableViewCell.h"
 
+#import "VLCBoxController.h"
+
 #import "VLC-Swift.h"
 
 @interface VLCServerListViewController () <UITableViewDataSource, UITableViewDelegate, VLCLocalServerDiscoveryControllerDelegate, VLCNetworkLoginViewControllerDelegate, VLCRemoteNetworkDataSourceDelegate, VLCFileServerViewDelegate>
@@ -65,6 +67,11 @@
 
     if (self) {
         [self setupUI];
+
+        // Start Box session on init to check whether it is logged in or not as soon as possible
+        [[VLCBoxController sharedInstance] startSession];
+        // Request directory listing to check authorization
+        [[VLCBoxController sharedInstance] requestDirectoryListingAtPath:nil];
     }
     return self;
 }
@@ -169,6 +176,7 @@
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange) name:kVLCThemeDidChangeNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentSizeDidChange) name:UIContentSizeCategoryDidChangeNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boxSessionUpdated) name:VLCBoxControllerSessionUpdated object:nil];
     [self themeDidChange];
     NSArray *browserClasses = @[
                                 [VLCLocalNetworkServiceBrowserUPnP class],
@@ -235,6 +243,16 @@
         loginViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) style:UIBarButtonItemStylePlain target:self action:@selector(_dismissLogin)];
 }
 
+- (void)boxSessionUpdated
+{
+    __weak typeof(self) weakSelf = self;
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        __strong typeof(weakSelf) strongSelf = weakSelf;
+        [strongSelf->_remoteNetworkTableView reloadData];
+    });
+}
+
 #pragma mark - table view handling
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

+ 0 - 1
Sources/VLCCloudServicesTableViewController.m

@@ -45,7 +45,6 @@
 
     self.dropboxTableViewController = [[VLCDropboxTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
     self.googleDriveTableViewController = [[VLCGoogleDriveTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
-    [[VLCBoxController sharedInstance] startSession];
     self.boxTableViewController = [[VLCBoxTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
     self.oneDriveTableViewController = [[VLCOneDriveTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
     self.documentPickerController = [VLCDocumentPickerController new];