marinofaggiana 4 سال پیش
والد
کامیت
17265b45b7
2فایلهای تغییر یافته به همراه12 افزوده شده و 5 حذف شده
  1. 1 1
      Nextcloud.xcodeproj/project.pbxproj
  2. 11 4
      iOSClient/Main/NCCollectionViewCommon.swift

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1028,8 +1028,8 @@
 		F7725A5D251F33BB00D125E0 /* Files */ = {
 			isa = PBXGroup;
 			children = (
-				F7725A5E251F33BB00D125E0 /* NCFiles.swift */,
 				F7725A5F251F33BB00D125E0 /* NCFiles.storyboard */,
+				F7725A5E251F33BB00D125E0 /* NCFiles.swift */,
 			);
 			path = Files;
 			sourceTree = "<group>";

+ 11 - 4
iOSClient/Main/NCCollectionViewCommon.swift

@@ -1228,6 +1228,16 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
 
 extension NCCollectionViewCommon: UICollectionViewDataSource {
 
+    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
+        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }
+        NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: appDelegate.urlBase, view: collectionView, indexPath: indexPath)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
+        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }        
+        NCOperationQueue.shared.cancelDownloadThumbnail(metadata: metadata)
+    }
+    
     func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
         
         if kind == UICollectionView.elementKindSectionHeader {
@@ -1278,10 +1288,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         var tableShare: tableShare?
         var isShare = false
         var isMounted = false
-        
-        // Download preview
-        NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: appDelegate.urlBase, view: collectionView, indexPath: indexPath)
-        
+                
         if metadataFolder != nil {
             isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder!.permissions.contains(k_permission_shared)
             isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder!.permissions.contains(k_permission_mounted)