marinofaggiana il y a 4 ans
Parent
commit
65e2182a15
1 fichiers modifiés avec 8 ajouts et 14 suppressions
  1. 8 14
      iOSClient/Media/NCMedia.swift

+ 8 - 14
iOSClient/Media/NCMedia.swift

@@ -439,24 +439,18 @@ extension NCMedia: UICollectionViewDataSource {
     }
 
     func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        DispatchQueue.global().async {
-            if indexPath.row < self.metadatas.count {
-                let metadata = self.metadatas[indexPath.row]
-                NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: self.appDelegate.activeUrl, view: self.collectionView as Any, indexPath: indexPath)
-            }
+        if indexPath.row < self.metadatas.count {
+            let metadata = self.metadatas[indexPath.row]
+            NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: self.appDelegate.activeUrl, view: self.collectionView as Any, indexPath: indexPath)
         }
     }
     
     func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        let indexPathsForVisibleItems = collectionView.indexPathsForVisibleItems
-        DispatchQueue.global().async {
-            if indexPath.row < self.metadatas.count {
-                let metadata = self.metadatas[indexPath.row]
-                for indexPath in indexPathsForVisibleItems {
-                    if indexPath.row < self.metadatas.count && metadata.ocId == self.metadatas[indexPath.row].ocId {
-                        return
-                    }
-                }
+        if collectionView.indexPathsForVisibleItems.contains(indexPath) {
+            return
+        } else {
+            if indexPath.row < metadatas.count {
+                let metadata = metadatas[indexPath.row]
                 NCOperationQueue.shared.cancelDownloadThumbnail(metadata: metadata)
             }
         }