marinofaggiana 3 жил өмнө
parent
commit
070881a432

+ 4 - 6
iOSClient/Main/NCFunctionCenter.swift

@@ -214,7 +214,7 @@ import NCCommunication
     
     // MARK: - Open in (files)
     
-    func openActivityViewController(metadatas: [tableMetadata]) {
+    func openActivityViewController(viewController: UIViewController, metadatas: [tableMetadata]) {
         
         var items: [Any] = []
         
@@ -224,11 +224,9 @@ import NCCommunication
         }
         
         let activityViewController = UIActivityViewController.init(activityItems: items, applicationActivities: nil)
-
-        if let view = appDelegate.window?.rootViewController?.view {
-            activityViewController.popoverPresentationController?.sourceView = view
-            appDelegate.window?.rootViewController?.present(activityViewController, animated: true)
-        }
+        activityViewController.popoverPresentationController?.sourceView = viewController.view
+        
+        viewController.present(activityViewController, animated: true)
     }
         
     // MARK: - Print

+ 6 - 5
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -417,14 +417,14 @@ extension NCCollectionViewCommon {
                         var metadatas: [tableMetadata] = []
                         for ocId in selectOcId {
                             if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
-                                let semaphore = Semaphore()
                                 if !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-                                    NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorOpenIn) { errorCode in
+                                    let semaphore = Semaphore()
+                                    NCNetworking.shared.download(metadata: metadata, selector: "") { errorCode in
                                         error = errorCode
                                         semaphore.continue()
                                     }
+                                    semaphore.wait()
                                 }
-                                semaphore.wait()
                                 if error != 0 {
                                     break
                                 }
@@ -432,8 +432,9 @@ extension NCCollectionViewCommon {
                             }
                         }
                         if error == 0 {
-                            NCFunctionCenter.shared.openActivityViewController(metadatas: metadatas)
-
+                            DispatchQueue.main.async {
+                                NCFunctionCenter.shared.openActivityViewController(viewController: viewController, metadatas: metadatas)
+                            }
                         }
                     }
                     self.tapSelect(sender: self)