Parcourir la source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana il y a 2 ans
Parent
commit
f413641cc7

+ 14 - 1
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -151,10 +151,23 @@ extension tableMetadata {
     }
 
     var isCopyableMovable: Bool {
-
         !isViewOnly && !isDirectoryE2EE && !e2eEncrypted
     }
 
+    var isModifiableWithQuickLook: Bool {
+        if directory || isViewOnly || isDirectoryE2EE {
+            return false
+        }
+        return contentType == "com.adobe.pdf" || contentType == "application/pdf" || classFile == NKCommon.typeClassFile.image.rawValue
+    }
+
+    var isDeletable: Bool {
+        if !isDirectoryE2EE && e2eEncrypted {
+            return false
+        }
+        return true
+    }
+
     var isDownloadUpload: Bool {
         status == NCGlobal.shared.metadataStatusInDownload || status == NCGlobal.shared.metadataStatusDownloading || status == NCGlobal.shared.metadataStatusInUpload || status == NCGlobal.shared.metadataStatusUploading
     }

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

@@ -323,9 +323,9 @@ extension NCCollectionViewCommon {
         }
         
         //
-        // MODIFY
+        // MODIFY WITH QUICK LOOK
         //
-        if !isDirectoryE2EE && metadata.contentType != "image/gif" && metadata.contentType != "image/svg+xml" && (metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" || metadata.classFile == NKCommon.typeClassFile.image.rawValue) {
+        if metadata.isModifiableWithQuickLook {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_modify_", comment: ""),
@@ -362,9 +362,7 @@ extension NCCollectionViewCommon {
         //
         // DELETE
         //
-        if !isDirectoryE2EE && metadata.e2eEncrypted {
-            print("Not possible delete")
-        } else {
+        if metadata.isDeletable {
             actions.append(.deleteAction(selectedMetadatas: [metadata], metadataFolder: metadataFolder, viewController: self, order: 170))
         }
 

+ 3 - 3
iOSClient/Menu/NCViewer+Menu.swift

@@ -240,9 +240,9 @@ extension NCViewer {
         }
 
         //
-        // MODIFY
+        // MODIFY WITH QUICK LOOK
         //
-        if !metadata.isDirectoryE2EE && !metadata.isViewOnly && metadata.contentType != "image/gif" && (metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" || metadata.classFile == NKCommon.typeClassFile.image.rawValue) {
+        if metadata.isModifiableWithQuickLook {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_modify_", comment: ""),
@@ -257,7 +257,7 @@ extension NCViewer {
         //
         // DELETE
         //
-        if !webView {
+        if !webView, metadata.isDeletable {
             actions.append(.deleteAction(selectedMetadatas: [metadata], metadataFolder: nil, viewController: viewController))
         }