Selaa lähdekoodia

#2125

Signed-off-by: marinofaggiana <marino.faggiana@nextcloud.com>
marinofaggiana 2 vuotta sitten
vanhempi
commit
c548b018e8

+ 14 - 7
iOSClient/Data/NCDataSource.swift

@@ -117,7 +117,7 @@ class NCDataSource: NSObject {
             if filterLivePhoto && metadata.livePhoto && metadata.ext == "mov" {
                 continue
             }
-            let section = NSLocalizedString(self.getSectionValue(metadata: metadata), comment: "").lowercased().firstUppercased
+            let section = NSLocalizedString(self.getSectionValue(metadata: metadata), comment: "")
             if !self.sectionsValue.contains(section) {
                 self.sectionsValue.append(section)
             }
@@ -127,15 +127,14 @@ class NCDataSource: NSObject {
         if let providers = self.providers, !providers.isEmpty {
             let sectionsDictionary = ThreadSafeDictionary<String,Int>()
             for section in self.sectionsValue {
-                if let provider = providers.filter({ $0.name.lowercased() == section.lowercased()}).first {
+                if let provider = providers.filter({ $0.id == section}).first {
                     sectionsDictionary[section] = provider.order
                 }
             }
             self.sectionsValue.removeAll()
             let sectionsDictionarySorted = sectionsDictionary.sorted(by: { $0.value < $1.value } )
-            let appName = NSLocalizedString(NCGlobal.shared.appName, comment: "").lowercased().firstUppercased
             for section in sectionsDictionarySorted {
-                if section.key == appName {
+                if section.key == NCGlobal.shared.appName {
                     self.sectionsValue.insert(section.key, at: 0)
                 } else {
                     self.sectionsValue.append(section.key)
@@ -172,7 +171,7 @@ class NCDataSource: NSObject {
 
         var searchResult: NCCSearchResult?
         if let providers = self.providers, !providers.isEmpty, let searchResults = self.searchResults {
-            searchResult = searchResults.filter({ $0.name == sectionValue}).first
+            searchResult = searchResults.filter({ $0.id == sectionValue}).first
         }
         let metadatas = self.metadatas.filter({ getSectionValue(metadata: $0) == sectionValue})
         let metadataForSection = NCMetadataForSection.init(sectionValue: sectionValue,
@@ -356,6 +355,14 @@ class NCDataSource: NSObject {
         return metadataForSection.sectionValue
     }
 
+    func getSectionValueLocalization(indexPath: IndexPath) -> String {
+        guard metadatasForSection.count > 0 , let metadataForSection = self.getMetadataForSection(indexPath.section) else { return ""}
+        if let searchResults = self.searchResults, let searchResult = searchResults.filter({ $0.id == metadataForSection.sectionValue}).first {
+            return searchResult.name
+        }
+        return metadataForSection.sectionValue
+    }
+
     func getFooterInformationAllMetadatas() -> (directories: Int, files: Int, size: Int64) {
 
         var directories: Int = 0
@@ -377,11 +384,11 @@ class NCDataSource: NSObject {
 
         switch self.groupByField {
         case "name":
-            return NSLocalizedString(metadata.name, comment: "").lowercased().firstUppercased
+            return NSLocalizedString(metadata.name, comment: "")
         case "classFile":
             return NSLocalizedString(metadata.classFile, comment: "").lowercased().firstUppercased
         default:
-            return NSLocalizedString(metadata.name, comment: "").lowercased().firstUppercased
+            return NSLocalizedString(metadata.classFile, comment: "")
         }
     }
 

+ 1 - 1
iOSClient/Data/NCDatabase.swift

@@ -386,7 +386,7 @@ class tableMetadata: Object, NCUserBaseUrl {
     @objc dynamic var isExtractFile: Bool = false
     @objc dynamic var livePhoto: Bool = false
     @objc dynamic var mountType = ""
-    @objc dynamic var name = ""
+    @objc dynamic var name = ""                                             // for unifiedSearch is the provider.id
     @objc dynamic var note = ""
     @objc dynamic var ocId = ""
     @objc dynamic var ownerId = ""

+ 2 - 3
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1707,9 +1707,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 header.setSectionHeight(heightHeaderSection)
                 if heightHeaderSection == 0 {
                     header.labelSection.text = ""
-
                 } else {
-                    header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath)
+                    header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
                 }
                 header.labelSection.textColor = NCBrandColor.shared.label
 
@@ -1719,7 +1718,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
                 let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
 
-                header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath)
+                header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
                 header.labelSection.textColor = NCBrandColor.shared.label
 
                 return header

+ 1 - 1
iOSClient/Networking/NCNetworking.swift

@@ -864,7 +864,7 @@ import Photos
                 })
             default:
                 partialResult.entries.forEach({ entry in
-                    let metadata = NCManageDatabase.shared.createMetadata(account: urlBase.account, user: urlBase.user, userId: urlBase.userId, fileName: entry.title, fileNameView: entry.title, ocId: NSUUID().uuidString, serverUrl: urlBase.urlBase, urlBase: urlBase.urlBase, url: entry.resourceURL, contentType: "", isUrl: true, name: partialResult.name.lowercased(), subline: entry.subline, iconName: entry.icon, iconUrl: entry.thumbnailURL)
+                    let metadata = NCManageDatabase.shared.createMetadata(account: urlBase.account, user: urlBase.user, userId: urlBase.userId, fileName: entry.title, fileNameView: entry.title, ocId: NSUUID().uuidString, serverUrl: urlBase.urlBase, urlBase: urlBase.urlBase, url: entry.resourceURL, contentType: "", isUrl: true, name: partialResult.id, subline: entry.subline, iconName: entry.icon, iconUrl: entry.thumbnailURL)
                     metadatas.append(metadata)
                 })
             }

+ 2 - 2
iOSClient/Select/NCSelect.swift

@@ -611,7 +611,7 @@ extension NCSelect: UICollectionViewDataSource {
                 if heightHeaderSection == 0 {
                     header.labelSection.text = ""
                 } else {
-                    header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath)
+                    header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
                 }
                 header.labelSection.textColor = NCBrandColor.shared.label
 
@@ -621,7 +621,7 @@ extension NCSelect: UICollectionViewDataSource {
 
                 let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
 
-                header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath)
+                header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
                 header.labelSection.textColor = NCBrandColor.shared.brandElement
 
                 return header