marinofaggiana 5 years ago
parent
commit
fc050fa976

+ 4 - 1
iOSClient/Favorites/CCFavorites.m

@@ -298,7 +298,10 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_all_task_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        [[NCMainCommon sharedInstance] cancelAllTransferWithView:self.view];
+        [NCUtility.sharedInstance startActivityIndicatorWithView:self.view bottom:0];
+        [[NCMainCommon sharedInstance] cancelAllTransfer];
+        [NCUtility.sharedInstance stopActivityIndicator];
+        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil fileID:nil action:k_action_NULL];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];

+ 4 - 1
iOSClient/Main/CCMain.m

@@ -1856,7 +1856,10 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_all_task_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        [[NCMainCommon sharedInstance] cancelAllTransferWithView:self.view];
+        [NCUtility.sharedInstance startActivityIndicatorWithView:self.view bottom:0];
+        [[NCMainCommon sharedInstance] cancelAllTransfer];
+        [NCUtility.sharedInstance stopActivityIndicator];
+        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil fileID:nil action:k_action_NULL];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];

+ 3 - 6
iOSClient/Main/NCMainCommon.swift

@@ -181,14 +181,12 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
         }
     }
     
-    @objc func cancelAllTransfer(view: UIView) {
+    @objc func cancelAllTransfer() {
         
         // Delete k_metadataStatusWaitUpload OR k_metadataStatusUploadError
         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "status == %d OR status == %d", appDelegate.activeAccount, k_metadataStatusWaitUpload, k_metadataStatusUploadError))
         
-        NCUtility.sharedInstance.startActivityIndicator(view: view, bottom: 0)
-        
-        DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
             if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "status != %d AND status != %d", k_metadataStatusNormal, k_metadataStatusHide), sorted: "fileName", ascending: true)  {
                 
                 for metadata in metadatas {
@@ -211,8 +209,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
         }
         
         DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-            self.reloadDatasource(ServerUrl: nil, fileID: nil, action: k_action_NULL)
-            NCUtility.sharedInstance.stopActivityIndicator()
+            return
         }
     }
     

+ 24 - 18
iOSClient/Settings/CCAdvanced.m

@@ -206,12 +206,14 @@
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC),dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        [[NSURLCache sharedURLCache] setMemoryCapacity:0];
-        [[NSURLCache sharedURLCache] setDiskCapacity:0];
-        [KTVHTTPCache cacheDeleteAllCaches];
-        
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+        [[NCMainCommon sharedInstance] cancelAllTransfer];
+
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
 
+            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+            [[NSURLCache sharedURLCache] setDiskCapacity:0];
+            [KTVHTTPCache cacheDeleteAllCaches];
+            
             [[NCManageDatabase sharedInstance] clearDatabaseWithAccount:appDelegate.activeAccount removeUser:false];
             
             [CCUtility emptyGroupDirectoryProviderStorage];
@@ -275,20 +277,24 @@
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             
             [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
-            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
-            [[NSURLCache sharedURLCache] setDiskCapacity:0];
-            [KTVHTTPCache cacheDeleteAllCaches];
-
-            [[NCManageDatabase sharedInstance] removeDB];
-            
-            [CCUtility emptyGroupDirectoryProviderStorage];
-            [CCUtility emptyGroupApplicationSupport];
-            [CCUtility emptyGroupCaches];
-            [CCUtility emptyDocumentsDirectory];
-            [CCUtility emptyTemporaryDirectory];
-            [CCUtility emptyLibraryDirectory];
             
-            [CCUtility deleteAllChainStore];
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                
+                [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+                [[NSURLCache sharedURLCache] setDiskCapacity:0];
+                [KTVHTTPCache cacheDeleteAllCaches];
+
+                [[NCManageDatabase sharedInstance] removeDB];
+                
+                [CCUtility emptyGroupDirectoryProviderStorage];
+                [CCUtility emptyGroupApplicationSupport];
+                [CCUtility emptyGroupCaches];
+                [CCUtility emptyDocumentsDirectory];
+                [CCUtility emptyTemporaryDirectory];
+                [CCUtility emptyLibraryDirectory];
+                
+                [CCUtility deleteAllChainStore];
+            });
             
             [self.hud hideHud];
             

+ 4 - 1
iOSClient/Transfers/CCTransfers.m

@@ -239,7 +239,10 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_all_task_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        [[NCMainCommon sharedInstance] cancelAllTransferWithView:self.view];
+        [NCUtility.sharedInstance startActivityIndicatorWithView:self.view bottom:0];
+        [[NCMainCommon sharedInstance] cancelAllTransfer];
+        [NCUtility.sharedInstance stopActivityIndicator];
+        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:nil fileID:nil action:k_action_NULL];
     }]];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];