marinofaggiana 5 жил өмнө
parent
commit
627b38a772

+ 1 - 1
iOSClient/Main/NCMainCommon.swift

@@ -1020,7 +1020,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                     }
                     
                     // Message
-                    let userInfo: [String : Any] = ["metadata": metadata, "errorCode": Int(errorCode)]
+                    let userInfo: [String : Any] = ["metadata": metadata, "errorCode": Int(errorCode), "errorDescription": completionMessage]
                     NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_deleteFile), object: nil, userInfo: userInfo)
                     
                     if count == metadatas.count {

+ 7 - 4
iOSClient/Media/NCMedia.swift

@@ -154,6 +154,12 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     }
 
     @objc func deleteFile(_ notification: NSNotification) {
+        if let userInfo = notification.userInfo as NSDictionary? {
+            if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int, let errorDescription = userInfo["errorDescription"] as? String {
+                self.selectocId.removeAll { $0 == metadata.ocId }
+                self.reloadDataSource(loadNetworkDatasource: false)
+            }
+        }
     }
     
     // MARK: DZNEmpty
@@ -526,10 +532,7 @@ extension NCMedia {
                 
         for ocId in selectocId {
             if let metadata = NCManageDatabase.sharedInstance.getMedia(predicate: NSPredicate(format: "ocId == %@", ocId)) {
-                NCNetworking.sharedInstance.deleteMetadata(metadata, notificationCenterPost: true) { (errorCode, errorDescription) in
-                    self.selectocId.removeAll { $0 == metadata.ocId }
-                    self.reloadDataSource(loadNetworkDatasource: false)
-                }
+                NCNetworking.sharedInstance.deleteMetadata(metadata, notificationCenterPost: true) { (errorCode, errorDescription) in }
             }
         }
     }

+ 7 - 7
iOSClient/Networking/NCNetworking.swift

@@ -253,7 +253,7 @@ import NCCommunication
         let permission = NCUtility.sharedInstance.permissionsContainsString(metadata.permissions, permissions: k_permission_can_delete)
         if metadata.permissions != "" && permission == false {
             if notificationCenterPost {
-                let userInfo: [String : Any] = ["metadata": metadata, "errorCode": Int(k_CCErrorNotPermission)]
+                let userInfo: [String : Any] = ["metadata": metadata, "errorCode": Int(k_CCErrorNotPermission), "errorDescription": NSLocalizedString("_no_permission_delete_file_", comment: "")]
                 NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_deleteFile), object: nil, userInfo: userInfo)
             }
             completion(Int(k_CCErrorNotPermission), "_no_permission_delete_file_")
@@ -262,6 +262,9 @@ import NCCommunication
                 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         NCCommunication.sharedInstance.deleteFileOrFolder(serverUrlFileName, account: metadata.account) { (account, errorCode, errorDescription) in
+            var description = ""
+            if errorDescription != nil { description = errorDescription! }
+            
             if errorCode == 0 || errorCode == kOCErrorServerPathNotFound {
                 
                 do {
@@ -277,15 +280,12 @@ import NCCommunication
                 }
             }
             
+            
             if notificationCenterPost {
-                let userInfo: [String : Any] = ["metadata": metadata, "errorCode": Int(errorCode)]
+                let userInfo: [String : Any] = ["metadata": metadata, "errorCode": Int(errorCode), "errorDescription": description]
                 NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_deleteFile), object: nil, userInfo: userInfo)
             }
-            if errorDescription != nil {
-                completion(errorCode, errorDescription!)
-            } else {
-                completion(errorCode, "")
-            }
+            completion(errorCode, description)
         }
     }
 }