Marino Faggiana 6 years ago
parent
commit
1e058a3786
1 changed files with 19 additions and 9 deletions
  1. 19 9
      iOSClient/Main/CCMain.m

+ 19 - 9
iOSClient/Main/CCMain.m

@@ -3820,22 +3820,32 @@
         
         
         if (directoryID) {
         if (directoryID) {
         
         
-            NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"directoryID == %@ AND status != %i", directoryID, k_metadataStatusHide] sorted:sorted ascending:[CCUtility getAscendingSettings]];
-                                                  
-            sectionDataSource = [CCSectionDataSourceMetadata new];
-            sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:_directoryGroupBy filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO activeAccount:appDelegate.activeAccount];
-            
-            // get auto upload folder
-            _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
-            _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl];
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                
+                CCSectionDataSourceMetadata *sectionDataSourceTemp = [CCSectionDataSourceMetadata new];
+
+                NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"directoryID == %@ AND status != %i", directoryID, k_metadataStatusHide] sorted:sorted ascending:[CCUtility getAscendingSettings]];
+                
+                sectionDataSourceTemp = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:_directoryGroupBy filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO activeAccount:appDelegate.activeAccount];
+                
+                // get auto upload folder
+                _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
+                _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl];
+            
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    sectionDataSource = sectionDataSourceTemp;
+                    [self tableViewReloadData];
+                });
+            });
         }
         }
         
         
     } else {
     } else {
         
         
+        [self tableViewReloadData];
+
          NSLog(@"[LOG] [OPTIMIZATION] Rebuild Data Source File : %@ - %@", _serverUrl, _dateReadDataSource);
          NSLog(@"[LOG] [OPTIMIZATION] Rebuild Data Source File : %@ - %@", _serverUrl, _dateReadDataSource);
     }
     }
     
     
-    [self tableViewReloadData];
 }
 }
 
 
 - (NSArray *)getMetadatasFromSelectedRows:(NSArray *)selectedRows
 - (NSArray *)getMetadatasFromSelectedRows:(NSArray *)selectedRows