Browse Source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
ceb5c5bad4

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

@@ -175,7 +175,15 @@ extension tableMetadata {
     var canOpenIn: Bool {
         return session.isEmpty && !isViewOnly && !directory && !NCBrandOptions.shared.disable_openin_file
     }
-    
+
+    var isDirectoySettableE2EE: Bool {
+        return directory && size == 0 && !e2eEncrypted && CCUtility.isEnd(toEndEnabled: account)
+    }
+
+    var isDirectoryUnsettableE2EE: Bool {
+        return !isDirectoryE2EE && directory && size == 0 && e2eEncrypted && CCUtility.isEnd(toEndEnabled: account)
+    }
+
     var canOpenExternalEditor: Bool {
         if isViewOnly {
             return false

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

@@ -132,7 +132,7 @@ extension NCCollectionViewCommon {
         //
         // SET FOLDER E2EE (ONLY ROOT)
         //
-        if metadata.serverUrl == serverUrlHome && metadata.directory && metadata.size == 0 && !metadata.e2eEncrypted && CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+        if metadata.serverUrl == serverUrlHome, metadata.isDirectoySettableE2EE {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_e2e_set_folder_encrypted_", comment: ""),
@@ -158,7 +158,7 @@ extension NCCollectionViewCommon {
         //
         // UNSET FOLDER E2EE
         //
-        if !isDirectoryE2EE && metadata.directory && metadata.size == 0 && metadata.e2eEncrypted && CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+        if metadata.isDirectoryUnsettableE2EE {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_e2e_remove_folder_encrypted_", comment: ""),
@@ -216,7 +216,7 @@ extension NCCollectionViewCommon {
         //
         // OPEN with external editor
         //
-        if !metadata.isViewOnly, metadata.classFile == NKCommon.typeClassFile.document.rawValue && editors.contains(NCGlobal.shared.editorText) && ((editors.contains(NCGlobal.shared.editorOnlyoffice) || isRichDocument)) {
+        if metadata.canOpenExternalEditor {
 
             var editor = ""
             var title = ""