瀏覽代碼

fix

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 年之前
父節點
當前提交
73574d3c22

+ 5 - 0
iOSClient/Data/NCDataSource.swift

@@ -82,6 +82,11 @@ class NCDataSource: NSObject {
         self.localFiles.removeAll()
         self.localFiles.removeAll()
     }
     }
 
 
+    func clearDirectory() {
+
+        self.directory = nil
+    }
+
     func addSection(metadatas: [tableMetadata], searchResult: NCCSearchResult?) {
     func addSection(metadatas: [tableMetadata], searchResult: NCCSearchResult?) {
 
 
         self.metadatasSource.append(contentsOf: metadatas)
         self.metadatasSource.append(contentsOf: metadatas)

+ 1 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -44,7 +44,7 @@ class NCFavorite: NCCollectionViewCommon {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         if !self.isSearching {
         if !self.isSearching {

+ 1 - 1
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -79,7 +79,7 @@ class NCFileViewInFolder: NCCollectionViewCommon {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         DispatchQueue.global().async {
         DispatchQueue.global().async {

+ 3 - 3
iOSClient/Files/NCFiles.swift

@@ -70,7 +70,7 @@ class NCFiles: NCCollectionViewCommon {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         guard !self.isSearching, !self.appDelegate.account.isEmpty, !self.appDelegate.urlBase.isEmpty else { return }
         guard !self.isSearching, !self.appDelegate.account.isEmpty, !self.appDelegate.urlBase.isEmpty else { return }
@@ -81,7 +81,7 @@ class NCFiles: NCCollectionViewCommon {
         }
         }
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, 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 {
+        if !forced, let directory = directory, directory.etag == self.dataSource.directory?.etag {
             return
             return
         }
         }
 
 
@@ -131,7 +131,7 @@ class NCFiles: NCCollectionViewCommon {
                 self.isReloadDataSourceNetworkInProgress = false
                 self.isReloadDataSourceNetworkInProgress = false
                 self.richWorkspaceText = tableDirectory?.richWorkspace
                 self.richWorkspaceText = tableDirectory?.richWorkspace
                 if metadatasUpdate?.count ?? 0 > 0 || metadatasDelete?.count ?? 0 > 0 || forced {
                 if metadatasUpdate?.count ?? 0 > 0 || metadatasDelete?.count ?? 0 > 0 || forced {
-                    self.reloadDataSource()
+                    self.reloadDataSource(forced: false)
                 } else {
                 } else {
                     self.collectionView?.reloadData()
                     self.collectionView?.reloadData()
                 }
                 }

+ 4 - 6
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -118,7 +118,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         // Refresh Control
         // Refresh Control
         collectionView.addSubview(refreshControl)
         collectionView.addSubview(refreshControl)
         refreshControl.action(for: .valueChanged) { _ in
         refreshControl.action(for: .valueChanged) { _ in
-            self.dataSource.clearDataSource()
+            self.dataSource.clearDirectory()
             self.reloadDataSourceNetwork(forced: true)
             self.reloadDataSourceNetwork(forced: true)
         }
         }
 
 
@@ -181,7 +181,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         navigationController?.setNavigationBarHidden(false, animated: true)
         navigationController?.setNavigationBarHidden(false, animated: true)
         setNavigationItem()
         setNavigationItem()
 
 
-        reloadDataSource()
+        reloadDataSource(forced: false)
     }
     }
 
 
     override func viewDidAppear(_ animated: Bool) {
     override func viewDidAppear(_ animated: Bool) {
@@ -285,7 +285,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
         }
 
 
         setNavigationItem()
         setNavigationItem()
-        reloadDataSource()
+        reloadDataSource(forced: false)
     }
     }
 
 
     @objc func changeThemingWithReloadData() {
     @objc func changeThemingWithReloadData() {
@@ -342,7 +342,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     }
 
 
     @objc func reloadDataSource(_ notification: NSNotification) {
     @objc func reloadDataSource(_ notification: NSNotification) {
-
         reloadDataSource()
         reloadDataSource()
     }
     }
 
 
@@ -437,7 +436,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     }
 
 
     @objc func renameFile(_ notification: NSNotification) {
     @objc func renameFile(_ notification: NSNotification) {
-
         reloadDataSource()
         reloadDataSource()
     }
     }
 
 
@@ -1008,7 +1006,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    @objc func reloadDataSource() {
+    @objc func reloadDataSource(forced: Bool = true) {
 
 
         if appDelegate.account == "" { return }
         if appDelegate.account == "" { return }
 
 

+ 2 - 2
iOSClient/Main/Collection Common/NCSelectableNavigationView.swift

@@ -45,7 +45,7 @@ protocol NCSelectableNavigationView: AnyObject {
 
 
     var selectActions: [NCMenuAction] { get }
     var selectActions: [NCMenuAction] { get }
 
 
-    func reloadDataSource()
+    func reloadDataSource(forced: Bool)
     func setNavigationItem()
     func setNavigationItem()
 
 
     func tapSelectMenu()
     func tapSelectMenu()
@@ -136,7 +136,7 @@ extension NCSelectableNavigationView where Self: UIViewController {
             actions.append(.saveMediaAction(selectedMediaMetadatas: selectedMediaMetadatas, completion: tapSelect))
             actions.append(.saveMediaAction(selectedMediaMetadatas: selectedMediaMetadatas, completion: tapSelect))
         }
         }
         actions.append(.setAvailableOfflineAction(selectedMetadatas: selectedMetadatas, isAnyOffline: isAnyOffline, viewController: self, completion: {
         actions.append(.setAvailableOfflineAction(selectedMetadatas: selectedMetadatas, isAnyOffline: isAnyOffline, viewController: self, completion: {
-            self.reloadDataSource()
+            self.reloadDataSource(forced: true)
             self.tapSelect()
             self.tapSelect()
         }))
         }))
 
 

+ 3 - 1
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -158,7 +158,9 @@ extension NCCollectionViewCommon {
         // OFFLINE
         // OFFLINE
         //
         //
         if !isFolderEncrypted {
         if !isFolderEncrypted {
-            actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: self, completion: self.reloadDataSource))
+            actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: self, completion: {
+                self.reloadDataSource(forced: true)
+            }))
         }
         }
 
 
         //
         //

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -44,7 +44,7 @@ class NCOffline: NCCollectionViewCommon {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         var ocIds: [String] = []
         var ocIds: [String] = []

+ 1 - 1
iOSClient/Recent/NCRecent.swift

@@ -44,7 +44,7 @@ class NCRecent: NCCollectionViewCommon {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         DispatchQueue.global().async {
         DispatchQueue.global().async {

+ 1 - 1
iOSClient/Shares/NCShares.swift

@@ -44,7 +44,7 @@ class NCShares: NCCollectionViewCommon {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         DispatchQueue.global().async {
         DispatchQueue.global().async {

+ 1 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -271,7 +271,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
 
 
     // MARK: - DataSource + NC Endpoint
     // MARK: - DataSource + NC Endpoint
 
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
         super.reloadDataSource()
 
 
         metadatasSource = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "status != %i", NCGlobal.shared.metadataStatusNormal), page: 1, limit: 100, sorted: "sessionTaskIdentifier", ascending: false)
         metadatasSource = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "status != %i", NCGlobal.shared.metadataStatusNormal), page: 1, limit: 100, sorted: "sessionTaskIdentifier", ascending: false)

+ 1 - 1
iOSClient/Trash/NCTrash.swift

@@ -241,7 +241,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
 
 
     // MARK: - DataSource
     // MARK: - DataSource
 
 
-    @objc func reloadDataSource() {
+    @objc func reloadDataSource(forced: Bool = true) {
 
 
         layoutForView = NCUtility.shared.getLayoutForView(key: NCGlobal.shared.layoutViewTrash, serverUrl: "")
         layoutForView = NCUtility.shared.getLayoutForView(key: NCGlobal.shared.layoutViewTrash, serverUrl: "")