marinofaggiana 6 years ago
parent
commit
a03ae18433
1 changed files with 10 additions and 20 deletions
  1. 10 20
      iOSClient/Media/NCMedia.swift

+ 10 - 20
iOSClient/Media/NCMedia.swift

@@ -255,7 +255,7 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
                 selectFileID.removeAll()
                 collectionView.reloadData()
             case 1: break
-           
+                deleteItems()
             default: ()
             }
         }
@@ -299,31 +299,21 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     
     // MARK: NC API
     
-    func deleteItem(with metadata: tableMetadata, sender: Any) {
+    func deleteItems() {
         
-        var items = [ActionSheetItem]()
+        var metadatas = [tableMetadata]()
         
-        guard let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == serverUrl", appDelegate.activeAccount, metadata.serverUrl)) else {
-            return
+        for fileID in selectFileID {
+            if let metadata = NCManageDatabase.sharedInstance.getTablePhoto(predicate: NSPredicate(format: "fileID == %@", fileID)) {
+                metadatas.append(metadata)
+            }
         }
         
-        items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
-        items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
-        
-        actionSheet = ActionSheet(items: items) { sheet, item in
-            if item is ActionSheetDangerButton {
-                NCMainCommon.sharedInstance.deleteFile(metadatas: [metadata], e2ee: tableDirectory.e2eEncrypted, serverUrl: tableDirectory.serverUrl, folderFileID: tableDirectory.fileID) { (errorCode, message) in
-                    self.collectionViewReloadDataSource()
-                }
+        if metadatas.count > 0 {
+            NCMainCommon.sharedInstance.deleteFile(metadatas: metadatas as NSArray, e2ee: false, serverUrl: "", folderFileID: "") { (errorCode, message) in
+                self.selectSearchSections()
             }
-            if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
         }
-        
-        let headerView = NCActionSheetHeader.sharedInstance.actionSheetHeader(isDirectory: metadata.directory, iconName: metadata.iconName, fileID: metadata.fileID, fileNameView: metadata.fileNameView, text: metadata.fileNameView)
-        actionSheet?.headerView = headerView
-        actionSheet?.headerView?.frame.size.height = 50
-        
-        actionSheet?.present(in: self, from: sender as! UIButton)
     }
     
     func search(lteDate: Date, gteDate: Date, addPast: Bool, setDistantPast: Bool) {