Browse Source

improved code (E2EE directory)

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

+ 10 - 1
iOSClient/Main/Create cloud/NCUploadAssets.swift

@@ -145,6 +145,15 @@ struct UploadAssetsView: View {
         }
     }
 
+    func getTextServerUrl(_ serverUrl: String) -> String {
+
+        if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", uploadAssets.userBaseUrl.account, serverUrl)), let metadata = NCManageDatabase.shared.getMetadataFromOcId(directory.ocId) {
+            return (metadata.fileNameView)
+        } else {
+            return (serverUrl as NSString).lastPathComponent
+        }
+    }
+
     func setFileNameMask(fileName: String?) -> String {
 
         guard let asset = uploadAssets.assets.first?.phAsset else { return "" }
@@ -354,7 +363,7 @@ struct UploadAssetsView: View {
                                 Text("/")
                                     .frame(maxWidth: .infinity, alignment: .trailing)
                             } else {
-                                Text((uploadAssets.serverUrl as NSString).lastPathComponent)
+                                Text(self.getTextServerUrl(uploadAssets.serverUrl))
                                     .frame(maxWidth: .infinity, alignment: .trailing)
                             }
                         } icon: {

+ 10 - 1
iOSClient/Scan document/NCUploadScanDocument.swift

@@ -372,6 +372,15 @@ struct UploadScanDocumentView: View {
         self.uploadScanDocument = uploadScanDocument
     }
 
+    func getTextServerUrl(_ serverUrl: String) -> String {
+
+        if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", uploadScanDocument.userBaseUrl.account, serverUrl)), let metadata = NCManageDatabase.shared.getMetadataFromOcId(directory.ocId) {
+            return (metadata.fileNameView)
+        } else {
+            return (serverUrl as NSString).lastPathComponent
+        }
+    }
+
     var body: some View {
 
         GeometryReader { geo in
@@ -384,7 +393,7 @@ struct UploadScanDocumentView: View {
                                     Text("/")
                                         .frame(maxWidth: .infinity, alignment: .trailing)
                                 } else {
-                                    Text((uploadScanDocument.serverUrl as NSString).lastPathComponent)
+                                    Text(self.getTextServerUrl(uploadScanDocument.serverUrl))
                                         .frame(maxWidth: .infinity, alignment: .trailing)
                                 }
                             } icon: {