marinofaggiana 4 лет назад
Родитель
Сommit
94446531a1

+ 13 - 8
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -707,17 +707,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     
     func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
-        if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) {
-            metadataTouch = metadata
-            longPressCollecationView(gestureRecognizer)
-        }
+        openMenuItems(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     
     func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
-        if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) {
-            metadataTouch = metadata
-            longPressCollecationView(gestureRecognizer)
-        }
+        openMenuItems(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     
     func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
@@ -727,9 +721,20 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     
     @objc func longPressCollecationView(_ gestureRecognizer: UILongPressGestureRecognizer) {
+        openMenuItems(with: nil, gestureRecognizer: gestureRecognizer)
+    }
+    
+    func openMenuItems(with objectId: String?, gestureRecognizer: UILongPressGestureRecognizer) {
+        
         if gestureRecognizer.state != .began { return }
         if serverUrl == "" { return }
         
+        if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) {
+            metadataTouch = metadata
+        } else {
+            metadataTouch = nil
+        }
+        
         var listMenuItems: [UIMenuItem] = []
         let touchPoint = gestureRecognizer.location(in: collectionView)
         

+ 0 - 2
iOSClient/Main/Colleaction Common/NCGridCell.swift

@@ -86,12 +86,10 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
     }
     
     @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) {
-        if gestureRecognizer.state != .began { return }
         delegate?.longPressMoreGridItem(with: objectId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer)
     }
     
     @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) {
-        if gestureRecognizer.state != .began { return }
         delegate?.longPressGridItem(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     

+ 0 - 2
iOSClient/Main/Colleaction Common/NCListCell.swift

@@ -96,12 +96,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
     }
     
     @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) {
-        if gestureRecognizer.state != .began { return }
         delegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer)
     }
     
     @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) {
-        if gestureRecognizer.state != .began { return }
         delegate?.longPressListItem(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     

+ 0 - 2
iOSClient/Transfers/NCTransferCell.swift

@@ -88,12 +88,10 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImage
     }
     
     @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) {
-        if gestureRecognizer.state != .began { return }
         delegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer)
     }
     
     @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) {
-        if gestureRecognizer.state != .began { return }
         delegate?.longPressListItem(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     

+ 6 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -157,7 +157,9 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate  {
     // MARK: TAP EVENT
     
     override func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
-      
+        
+        if gestureRecognizer.state != .began { return }
+        
         let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .alert)
        
         alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil))
@@ -171,6 +173,9 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate  {
     }
     
     override func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
+        
+        if gestureRecognizer.state != .began { return }
+        
         if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) {
             metadataTemp = metadata
             let touchPoint = gestureRecognizer.location(in: collectionView)