فهرست منبع

Fix out of range media cell

Signed-off-by: Philippe Weidmann <philippe.weidmann@infomaniak.com>
Philippe Weidmann 4 سال پیش
والد
کامیت
598b5bba1c
1فایلهای تغییر یافته به همراه8 افزوده شده و 4 حذف شده
  1. 8 4
      iOSClient/Media/NCMedia.swift

+ 8 - 4
iOSClient/Media/NCMedia.swift

@@ -431,13 +431,17 @@ extension NCMedia: UICollectionViewDataSource {
     }
     }
 
 
     func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
     func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        let metadata = metadatas[indexPath.row]
-        NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: self.appDelegate.activeUrl, view: self.collectionView as Any, indexPath: indexPath)
+        if indexPath.row < metadatas.count {
+            let metadata = 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) {
     func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        let metadata = metadatas[indexPath.row]
-        NCOperationQueue.shared.cancelDownloadThumbnail(metadata: metadata)
+        if indexPath.row < metadatas.count {
+            let metadata = metadatas[indexPath.row]
+            NCOperationQueue.shared.cancelDownloadThumbnail(metadata: metadata)
+        }
     }
     }
 
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {