Browse Source

Update library NCCommunication

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 years ago
parent
commit
53d1bea46a
1 changed files with 23 additions and 18 deletions
  1. 23 18
      Share/NCShareExtension.swift

+ 23 - 18
Share/NCShareExtension.swift

@@ -705,17 +705,19 @@ extension NCShareExtension {
         
         NCNetworking.shared.createFolder(fileName: fileName, serverUrl: serverUrl, account: activeAccount.account, urlBase: activeAccount.urlBase) { (errorCode, errorDescription) in
             
-            if errorCode == 0 {
-                
-                self.serverUrl = self.serverUrl + "/" + fileName
-                self.reloadDatasource(withLoadFolder: true)
-                self.setNavigationBar(navigationTitle: fileName)
-                
-            }  else {
-                
-                let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
-                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
-                self.present(alertController, animated: true)
+            DispatchQueue.main.async {
+                if errorCode == 0 {
+                    
+                    self.serverUrl = self.serverUrl + "/" + fileName
+                    self.reloadDatasource(withLoadFolder: true)
+                    self.setNavigationBar(navigationTitle: fileName)
+                    
+                }  else {
+                    
+                    let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
+                    alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+                    self.present(alertController, animated: true)
+                }
             }
         }
     }
@@ -726,14 +728,17 @@ extension NCShareExtension {
         collectionView.reloadData()
         
         NCNetworking.shared.readFolder(serverUrl: serverUrl, account: activeAccount.account) { (_, metadataFolder, _, _, _, _, errorCode, errorDescription) in
-            if errorCode != 0 {
-                let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
-                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
-                self.present(alertController, animated: true)
+            
+            DispatchQueue.main.async {
+                if errorCode != 0 {
+                    let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
+                    alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+                    self.present(alertController, animated: true)
+                }
+                self.networkInProgress = false
+                self.metadataFolder = metadataFolder
+                self.reloadDatasource(withLoadFolder: false)
             }
-            self.networkInProgress = false
-            self.metadataFolder = metadataFolder
-            self.reloadDatasource(withLoadFolder: false)
         }
     }