Browse Source

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
b3256e9e50
1 changed files with 14 additions and 4 deletions
  1. 14 4
      iOSClient/Data/NCDataSource.swift

+ 14 - 4
iOSClient/Data/NCDataSource.swift

@@ -75,9 +75,19 @@ class NCDataSource: NSObject {
 
         self.sectionsValue = metadatasSource.map { getSectionValue(metadata: $0) }
         self.sectionsValue = Array(Set(self.sectionsValue))
-//        if let providers = self.providers {
-
-//        } else {
+        if let providers = self.providers {
+            var sectionsDictionary: [String:Int] = [:]
+            for section in self.sectionsValue {
+                if let provider = providers.filter({ $0.name.lowercased() == section.lowercased()}).first {
+                    sectionsDictionary[section] = provider.order
+                }
+            }
+            self.sectionsValue.removeAll()
+            let sectionsDictionarySorted = sectionsDictionary.sorted(by: { $0.value > $1.value } )
+            for section in sectionsDictionarySorted { self.sectionsValue.append(section.key) }
+            print(sectionsDictionarySorted)
+            print(self.sectionsValue)
+        } else {
             self.sectionsValue = self.sectionsValue.sorted {
                 if self.ascending {
                     return $0 < $1
@@ -85,7 +95,7 @@ class NCDataSource: NSObject {
                     return $0 > $1
                 }
             }
-//        }
+        }
     }
 
     internal func createMetadataForSection(sectionValue: String) {