浏览代码

Test

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 年之前
父节点
当前提交
22609e204f
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 3 1
      iOSClient/Data/NCDataSource.swift
  2. 7 1
      iOSClient/Files/NCFiles.swift

+ 3 - 1
iOSClient/Data/NCDataSource.swift

@@ -28,6 +28,7 @@ class NCDataSource: NSObject {
 
     public var metadatasSource: [tableMetadata] = []
     public var metadatasForSection: [NCMetadataForSection] = []
+    public var directory: tableDirectory?
 
     private var sectionsValue: [String] = []
     private var providers: [NCCSearchProvider]?
@@ -46,10 +47,11 @@ class NCDataSource: NSObject {
         super.init()
     }
 
-    init(metadatasSource: [tableMetadata], account: String, sort: String? = "none", ascending: Bool? = false, directoryOnTop: Bool? = true, favoriteOnTop: Bool? = true, filterLivePhoto: Bool? = true, groupByField: String = "name", providers: [NCCSearchProvider]? = nil, searchResults: [NCCSearchResult]? = nil) {
+    init(metadatasSource: [tableMetadata], account: String, directory: tableDirectory? = nil, sort: String? = "none", ascending: Bool? = false, directoryOnTop: Bool? = true, favoriteOnTop: Bool? = true, filterLivePhoto: Bool? = true, groupByField: String = "name", providers: [NCCSearchProvider]? = nil, searchResults: [NCCSearchResult]? = nil) {
         super.init()
 
         self.metadatasSource = metadatasSource
+        self.directory = directory
         self.shares = NCManageDatabase.shared.getTableShares(account: account)
         self.localFiles = NCManageDatabase.shared.getTableLocalFile(account: account)
         self.sort = sort ?? "none"

+ 7 - 1
iOSClient/Files/NCFiles.swift

@@ -79,10 +79,16 @@ class NCFiles: NCCollectionViewCommon {
         if self.metadataFolder == nil {
             self.metadataFolder = NCManageDatabase.shared.getMetadataFolder(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, serverUrl: self.serverUrl)
         }
+        let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, self.serverUrl))
+
+        if let directory = directory, directory.etag == self.dataSource.directory?.etag {
+            return
+        }
 
         self.dataSource = NCDataSource(
             metadatasSource: self.metadatasSource,
             account: self.appDelegate.account,
+            directory: directory,
             sort: self.layoutForView?.sort,
             ascending: self.layoutForView?.ascending,
             directoryOnTop: self.layoutForView?.directoryOnTop,
@@ -121,7 +127,6 @@ class NCFiles: NCCollectionViewCommon {
             }
 
             DispatchQueue.main.async {
-                self.refreshControl.endRefreshing()
                 self.isReloadDataSourceNetworkInProgress = false
                 self.richWorkspaceText = tableDirectory?.richWorkspace
                 if metadatasUpdate?.count ?? 0 > 0 || metadatasDelete?.count ?? 0 > 0 || forced {
@@ -129,6 +134,7 @@ class NCFiles: NCCollectionViewCommon {
                 } else {
                     self.collectionView?.reloadData()
                 }
+                self.refreshControl.endRefreshing()
             }
         }
     }