Sfoglia il codice sorgente

fix cancel download

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 anni fa
parent
commit
cdbcd8e2bf

+ 2 - 4
iOSClient/Data/NCDataSource.swift

@@ -28,6 +28,8 @@ class NCDataSource: NSObject {
     public var metadatasSource: [tableMetadata] = []
     public var metadatasForSection: [NCMetadatasForSection] = []
 
+    private var sectionsValue: [String] = []
+
     private var ascending: Bool = true
     private var sort: String = ""
     private var directoryOnTop: Bool = true
@@ -35,8 +37,6 @@ class NCDataSource: NSObject {
     private var filterLivePhoto: Bool = true
     private var groupByField: String = ""
 
-    private var sectionsValue: [String] = []
-
     override init() {
         super.init()
     }
@@ -52,10 +52,8 @@ class NCDataSource: NSObject {
         self.filterLivePhoto = filterLivePhoto ?? true
         self.groupByField = groupByField
 
-        // Create sections && sorted
         createSections()
 
-        // Create metadataForSection
         for sectionValue in self.sectionsValue {
             createMetadataForSection(sectionValue: sectionValue)
         }

+ 11 - 15
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -988,25 +988,21 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
         let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
         if serverVersionMajor >= NCGlobal.shared.nextcloudVersion20 {
+            self.refreshControl.beginRefreshing()
             NCNetworking.shared.unifiedSearchFiles(urlBase: appDelegate, literal: literalSearch, update: { metadatas in
                 guard let metadatas = metadatas, metadatas.count > 0 else { return }
                 DispatchQueue.main.async {
-                    // update
-                    /*
-                    var indexPaths: [IndexPath] = []
-                    guard let metadatas = metadatas else { return }
-                    for metadata in metadatas {
-                        if let indexPath = self.dataSource.addMetadata(metadata, withCreateMetadatas: false) {
-                            indexPaths.append(indexPath)
-                        }
+                    if self.searchController?.isActive == true {
+                        self.metadatasSource = metadatas
+                        self.dataSource = NCDataSource(
+                            metadatasSource: self.metadatasSource,
+                            sort: self.layoutForView?.sort,
+                            ascending: self.layoutForView?.ascending,
+                            directoryOnTop: self.layoutForView?.directoryOnTop,
+                            favoriteOnTop: true,
+                            filterLivePhoto: true)
+                        self.collectionView.reloadData()
                     }
-                    self.metadatasSource = self.dataSource.createMetadatas()
-                    self.collectionView?.performBatchUpdates({
-                        self.collectionView?.insertItems(at: indexPaths)
-                    }, completion: { _ in
-                        self.collectionView?.reloadData()
-                    })
-                    */
                 }
             }, completion: completionHandler)
         } else {