Explorar o código

cleaning

Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com>
Marino Faggiana hai 1 ano
pai
achega
5c5fada014

+ 9 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1201,7 +1201,15 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                     if let image = NCUtility.shared.createFilePreviewImage(ocId: metadata.ocId, etag: metadata.etag, fileNameView: metadata.fileNameView, classFile: metadata.classFile, status: metadata.status, createPreviewMedia: !metadata.hasPreview) {
                     (cell as? NCCellProtocol)?.filePreviewImageView?.image = image
                 } else {
-                    NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: true, cell: cell, view: collectionView)
+                    if metadata.iconName.isEmpty {
+                        (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.file
+                    } else {
+                        (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
+                    }
+                    if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
+                        for case let operation as NCOperationDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
+                        appDelegate.downloadThumbnailQueue.addOperation(NCOperationDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), view: view))
+                    }
                 }
             } else {
                 // Unified search

+ 4 - 1
iOSClient/Media/NCMedia.swift

@@ -380,7 +380,10 @@ extension NCMedia: UICollectionViewDataSource {
                 NCMediaManager.shared.setImage(ocId: metadata.ocId, image: image)
             }
         } else {
-            NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: false, cell: cell, view: collectionView)
+            if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
+                for case let operation as NCOperationDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
+                appDelegate.downloadThumbnailQueue.addOperation(NCOperationDownloadThumbnail(metadata: metadata, cell: cell, view: view))
+            }
         }
     }
 

+ 0 - 22
iOSClient/Networking/NCOperationQueue.swift

@@ -42,28 +42,6 @@ import JGProgressHUD
         appDelegate.downloadQueue.addOperation(NCOperationDownload(metadata: metadata, selector: selector))
     }
 
-    // MARK: - Download Thumbnail
-
-    func downloadThumbnail(metadata: tableMetadata, placeholder: Bool, cell: UIView?, view: UIView?) {
-
-        let cell: NCCellProtocol? = cell as? NCCellProtocol
-
-        if placeholder {
-            if metadata.iconName.isEmpty {
-                cell?.filePreviewImageView?.image = NCBrandColor.cacheImages.file
-            } else {
-                cell?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
-            }
-        }
-
-        if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
-            for case let operation as NCOperationDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
-            appDelegate.downloadThumbnailQueue.addOperation(NCOperationDownloadThumbnail(metadata: metadata, cell: cell, view: view))
-        }
-    }
-
-    
-
     // MARK: - Download Thumbnail Activity
 
     func downloadThumbnailActivity(fileNamePathOrFileId: String, fileNamePreviewLocalPath: String, fileId: String, cell: NCActivityCollectionViewCell, collectionView: UICollectionView?) {

+ 10 - 1
iOSClient/Select/NCSelect.swift

@@ -35,6 +35,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
     @IBOutlet private var buttonCancel: UIBarButtonItem!
     @IBOutlet private var bottomContraint: NSLayoutConstraint?
 
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var selectCommandViewSelect: NCSelectCommandView?
 
     @objc enum selectType: Int {
@@ -300,7 +301,15 @@ extension NCSelect: UICollectionViewDataSource {
             if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
                 (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
             } else {
-                NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: true, cell: cell, view: collectionView)
+                if metadata.iconName.isEmpty {
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.file
+                } else {
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
+                }
+                if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
+                    for case let operation as NCOperationDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
+                    appDelegate.downloadThumbnailQueue.addOperation(NCOperationDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), view: view))
+                }
             }
         }