marinofaggiana 4 年之前
父节点
当前提交
7051739030

+ 4 - 2
iOSClient/Favorites/NCFavorite.swift

@@ -96,7 +96,7 @@ class NCFavorite: NCCollectionViewCommon  {
             
         } else {
             
-            networkReadFolder(forced: forced) { (metadatas, errorCode, errorDescription) in
+            networkReadFolder(forced: forced) { (metadatas, metadatasUpdate, errorCode, errorDescription) in
                 if errorCode == 0 {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory {
@@ -108,7 +108,9 @@ class NCFavorite: NCCollectionViewCommon  {
                     }
                 }
                 self.isReloadDataSourceNetworkInProgress = false
-                self.reloadDataSource()
+                if metadatasUpdate?.count ?? 0 > 0 {
+                    self.reloadDataSource()
+                }
             }
         }
     }

+ 4 - 2
iOSClient/Files/NCFiles.swift

@@ -91,7 +91,7 @@ class NCFiles: NCCollectionViewCommon  {
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
                
-        networkReadFolder(forced: forced) { (metadatas, errorCode, errorDescription) in
+        networkReadFolder(forced: forced) { (metadatas, metadatasUpdate, errorCode, errorDescription) in
             if errorCode == 0 {
                 for metadata in metadatas ?? [] {
                     if !metadata.directory {
@@ -103,7 +103,9 @@ class NCFiles: NCCollectionViewCommon  {
                 }
             }
             self.isReloadDataSourceNetworkInProgress = false
-            self.reloadDataSource()
+            if metadatasUpdate?.count ?? 0 > 0 {
+                self.reloadDataSource()
+            }
         }
     }
 }

+ 2 - 3
iOSClient/Main/Collection/NCCollectionCommon.swift

@@ -31,8 +31,6 @@ class NCCollectionCommon: NSObject {
         return instance
     }()
     
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
     struct NCCollectionCommonImages {
         static var cellSharedImage = UIImage()
         static var cellCanShareImage = UIImage()
@@ -86,6 +84,7 @@ class NCCollectionCommon: NSObject {
     func cellForItemAt(indexPath: IndexPath, collectionView: UICollectionView, cell: UICollectionViewCell, metadata: tableMetadata, metadataFolder: tableMetadata?, serverUrl: String, isEditMode: Bool, isEncryptedFolder: Bool, selectocId: [String], autoUploadFileName: String, autoUploadDirectory: String, hideButtonMore: Bool, downloadThumbnail: Bool, shares: [tableShare]?, source: UIViewController, dataSource: NCDataSource?) {
         
         var tableShare: tableShare?
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
         
         // Share
         if shares != nil {
@@ -222,7 +221,7 @@ class NCCollectionCommon: NSObject {
                     cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                 } else {
                     NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: Int(k_avatar_size)) { (account, data, errorCode, errorMessage) in
-                        if errorCode == 0 && account == self.appDelegate.account {
+                        if errorCode == 0 && account == appDelegate.account {
                             cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                         }
                     }

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

@@ -932,7 +932,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
     
-    @objc func networkReadFolder(forced: Bool, completion: @escaping(_ metadatas: [tableMetadata]?, _ errorCode: Int, _ errorDescription: String)->()) {
+    @objc func networkReadFolder(forced: Bool, completion: @escaping(_ metadatas: [tableMetadata]?, _ metadatasUpdate: [tableMetadata]?, _ errorCode: Int, _ errorDescription: String)->()) {
         NCNetworking.shared.readFile(serverUrlFileName: serverUrl, account: appDelegate.account) { (account, metadata, errorCode, errorDescription) in
             if errorCode == 0 {
                 let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
@@ -941,13 +941,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                         if errorCode == 0 {
                             self.metadataFolder = metadataFolder
                         }
-                        completion(metadatas, errorCode, errorDescription)
+                        completion(metadatas, metadatasUpdate, errorCode, errorDescription)
                     }
                 } else {
-                    completion(nil, 0, "")
+                    completion(nil, nil, 0, "")
                 }
             } else {
-               completion(nil, errorCode, errorDescription)
+               completion(nil, nil, errorCode, errorDescription)
             }
         }
     }

+ 4 - 2
iOSClient/Offline/NCOffline.swift

@@ -96,7 +96,7 @@ class NCOffline: NCCollectionViewCommon  {
             isReloadDataSourceNetworkInProgress = true
             collectionView?.reloadData()
             
-            networkReadFolder(forced: forced) { (metadatas, errorCode, errorDescription) in
+            networkReadFolder(forced: forced) { (metadatas, metadatasUpdate, errorCode, errorDescription) in
                 if errorCode == 0 {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory {
@@ -108,7 +108,9 @@ class NCOffline: NCCollectionViewCommon  {
                     }
                 }
                 self.isReloadDataSourceNetworkInProgress = false
-                self.reloadDataSource()
+                if metadatasUpdate?.count ?? 0 > 0 {
+                    self.reloadDataSource()
+                }
             }
         }
     }