Browse Source

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 3 years ago
parent
commit
8c68e5f775

+ 7 - 10
iOSClient/Data/NCDataSource.swift

@@ -79,14 +79,6 @@ class NCDataSource: NSObject {
 
         self.sectionsValue = metadatasSource.map { getSectionValue(metadata: $0) }
         self.sectionsValue = Array(Set(self.sectionsValue))
-        self.sectionsValue = self.sectionsValue.sorted {
-            if self.ascending {
-                return $0 < $1
-            } else {
-                return $0 > $1
-            }
-        }
-        /* TEST
         if let providers = self.providers {
             var sectionsDictionary: [String:Int] = [:]
             for section in self.sectionsValue {
@@ -96,7 +88,13 @@ class NCDataSource: NSObject {
             }
             self.sectionsValue.removeAll()
             let sectionsDictionarySorted = sectionsDictionary.sorted(by: { $0.value > $1.value } )
-            for section in sectionsDictionarySorted { self.sectionsValue.append(section.key) }
+            for section in sectionsDictionarySorted {
+                if section.key == NCGlobal.shared.appName {
+                    self.sectionsValue.insert(section.key, at: 0)
+                } else {
+                    self.sectionsValue.append(section.key)
+                }
+            }
         } else {
             self.sectionsValue = self.sectionsValue.sorted {
                 if self.ascending {
@@ -106,7 +104,6 @@ class NCDataSource: NSObject {
                 }
             }
         }
-        */
     }
 
     internal func createMetadataForSection(sectionValue: String) {

+ 2 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -62,7 +62,8 @@ class NCFavorite: NCCollectionViewCommon {
                                        directoryOnTop: self.layoutForView?.directoryOnTop,
                                        favoriteOnTop: true,
                                        filterLivePhoto: true,
-                                       groupByField: self.groupByField)
+                                       groupByField: self.groupByField,
+                                       providers: self.providers)
 
         DispatchQueue.main.async {
             self.refreshControl.endRefreshing()

+ 2 - 1
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -98,7 +98,8 @@ class NCFileViewInFolder: NCCollectionViewCommon {
                                            directoryOnTop: self.layoutForView?.directoryOnTop,
                                            favoriteOnTop: true,
                                            filterLivePhoto: true,
-                                           groupByField: self.groupByField)
+                                           groupByField: self.groupByField,
+                                           providers: self.providers)
 
             DispatchQueue.main.async {
 

+ 2 - 1
iOSClient/Files/NCFiles.swift

@@ -88,7 +88,8 @@ class NCFiles: NCCollectionViewCommon {
             directoryOnTop: self.layoutForView?.directoryOnTop,
             favoriteOnTop: true,
             filterLivePhoto: true,
-            groupByField: self.groupByField)
+            groupByField: self.groupByField,
+            providers: self.providers)
 
         DispatchQueue.main.async {
             self.refreshControl.endRefreshing()

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

@@ -52,6 +52,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     private var autoUploadDirectory = ""
 
     internal var groupByField = "name"
+    internal var providers: [NCCSearchProvider]?
 
     internal var listLayout: NCListLayout!
     internal var gridLayout: NCGridLayout!
@@ -737,6 +738,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         self.isSearching = true
 
+        self.providers?.removeAll()
         self.metadatasSource.removeAll()
         self.dataSource.clearDataSource()
 
@@ -757,6 +759,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
         self.isSearching = false
         self.literalSearch = ""
+        self.providers?.removeAll()
 
         reloadDataSource()
     }
@@ -1025,7 +1028,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 self.reloadDataSource()
             }
         }
-        var providers: [NCCSearchProvider]?
 
         isReloadDataSourceNetworkInProgress = true
         self.metadatasSource.removeAll()
@@ -1036,7 +1038,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if serverVersionMajor >= NCGlobal.shared.nextcloudVersion20 {
             self.refreshControl.beginRefreshing()
             NCNetworking.shared.unifiedSearchFiles(urlBase: appDelegate, literal: literalSearch) { allProviders in
-                providers = allProviders
+                self.providers = allProviders
             } update: { metadatas in
                 guard let metadatas = metadatas, metadatas.count > 0 else { return }
                 DispatchQueue.main.async {
@@ -1049,7 +1051,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                                                        directoryOnTop: self.layoutForView?.directoryOnTop,
                                                        favoriteOnTop: true,
                                                        filterLivePhoto: true,
-                                                       providers: providers)
+                                                       providers: self.providers)
                         self.collectionView.reloadData()
                     }
                 }

+ 2 - 1
iOSClient/Offline/NCOffline.swift

@@ -76,7 +76,8 @@ class NCOffline: NCCollectionViewCommon {
             directoryOnTop: self.layoutForView?.directoryOnTop,
             favoriteOnTop: true,
             filterLivePhoto: true,
-            groupByField: self.groupByField)
+            groupByField: self.groupByField,
+            providers: self.providers)
 
         DispatchQueue.main.async {
             self.refreshControl.endRefreshing()

+ 2 - 1
iOSClient/Recent/NCRecent.swift

@@ -54,7 +54,8 @@ class NCRecent: NCCollectionViewCommon {
                                            account: self.appDelegate.account,
                                            directoryOnTop: false,
                                            favoriteOnTop: false,
-                                           groupByField: self.groupByField)
+                                           groupByField: self.groupByField,
+                                           providers: self.providers)
 
             DispatchQueue.main.async {
                 self.refreshControl.endRefreshing()

+ 2 - 1
iOSClient/Shares/NCShares.swift

@@ -65,7 +65,8 @@ class NCShares: NCCollectionViewCommon {
                                            directoryOnTop: self.layoutForView?.directoryOnTop,
                                            favoriteOnTop: true,
                                            filterLivePhoto: true,
-                                           groupByField: self.groupByField)
+                                           groupByField: self.groupByField,
+                                           providers: self.providers)
 
             DispatchQueue.main.async {
                 self.refreshControl.endRefreshing()