Marino Faggiana 6 years ago
parent
commit
0b47d35af2

+ 9 - 2
iOSClient/Favorites/CCFavorites.m

@@ -98,8 +98,6 @@
     
     // Plus Button
     [appDelegate plusButtonVisibile:true];
-    
-    [self reloadDatasource:nil action:k_action_NULL];
 }
 
 // E' arrivato
@@ -109,6 +107,10 @@
     
     // Active Main
     appDelegate.activeFavorites = self;
+    
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+        [self reloadDatasource:nil action:k_action_NULL];
+    });
 }
 
 - (void)changeTheming
@@ -552,6 +554,11 @@
 
 - (void)reloadDatasource:(NSString *)fileID action:(NSInteger)action
 {
+    // test
+    if (appDelegate.activeAccount.length == 0 || self.view.window == nil) {
+        return;
+    }
+    
     NSArray *recordsTableMetadata ;
     
     NSString *sorted = [CCUtility getOrderSettings];

+ 4 - 15
iOSClient/Main/CCMain.m

@@ -1296,7 +1296,9 @@
         return;
     
     // Load Datasource
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl fileID:nil action:k_action_NULL];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl fileID:nil action:k_action_NULL];
+    });
     
     CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
 
@@ -3738,7 +3740,7 @@
 - (void)reloadDatasource:(NSString *)serverUrl fileID:(NSString *)fileID action:(NSInteger)action
 {
     // test
-    if (appDelegate.activeAccount.length == 0 || serverUrl.length == 0 || serverUrl == nil)
+    if (appDelegate.activeAccount.length == 0 || serverUrl.length == 0 || serverUrl == nil || self.view.window == nil)
         return;
     
     // Search Mode
@@ -3774,19 +3776,6 @@
         return;
     }
     
-    // Reload -> Self se non siamo nella dir appropriata cercala e se è in memoria reindirizza il reload
-    if ([serverUrl isEqualToString:_serverUrl] == NO || _serverUrl == nil) {
-        
-        CCMain *main = [appDelegate.listMainVC objectForKey:serverUrl];
-        if (main) {
-            [main reloadDatasource:serverUrl fileID:fileID action:action];
-        } else {
-            [self tableViewReloadData];
-        }
-        
-        return;
-    }
-        
     // Settaggio variabili per le ottimizzazioni
     _directoryGroupBy = [CCUtility getGroupBySettings];
     _directoryOrder = [CCUtility getOrderSettings];

+ 6 - 5
iOSClient/Media/CCMedia.m

@@ -110,10 +110,9 @@
     scrollBar.edgeInset = 12;
 }
 
-// Apparirà
-- (void)viewWillAppear:(BOOL)animated
+- (void)viewDidAppear:(BOOL)animated
 {
-    [super viewWillAppear:animated];
+    [super viewDidAppear:animated];
     
     // Color
     [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
@@ -122,7 +121,9 @@
     // Plus Button
     [appDelegate plusButtonVisibile:true];
 
-    [self reloadDatasource:nil action:k_action_NULL];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+        [self reloadDatasource:nil action:k_action_NULL];
+    });
 }
 
 - (void)viewSafeAreaInsetsDidChange
@@ -624,7 +625,7 @@
 - (void)reloadDatasource:(NSString *)fileID action:(NSInteger)action
 {
     // test
-    if (appDelegate.activeAccount.length == 0) {
+    if (appDelegate.activeAccount.length == 0 || self.view.window == nil) {
         return;
     }
     

+ 4 - 3
iOSClient/Transfers/CCTransfers.m

@@ -91,7 +91,9 @@
     [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
     [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
     
-    [self reloadDatasource:nil action:k_action_NULL];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+        [self reloadDatasource:nil action:k_action_NULL];
+    });
 }
 
 - (void)changeTheming
@@ -213,9 +215,8 @@
 - (void)reloadDatasource:(NSString *)fileID action:(NSInteger)action
 {
     // test
-    if (appDelegate.activeAccount.length == 0 || !self.view.window)
+    if (appDelegate.activeAccount.length == 0 || self.view.window == nil)
         return;
-    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND ((session CONTAINS 'upload') OR (session CONTAINS 'download'))", appDelegate.activeAccount] sorted:@"sessionTaskIdentifier" ascending:NO];