marinofaggiana 4 жил өмнө
parent
commit
eb969ce9d7

+ 22 - 18
iOSClient/Main/NCCollectionCommon.swift

@@ -121,6 +121,9 @@ class NCCollectionCommon: NSObject {
             cell.imageFavorite.image = nil
             cell.imageShared.image = nil
             
+            cell.imageItem.image = nil
+            cell.imageItem.backgroundColor = nil
+            
             if metadata.directory {
                 
                 if metadata.e2eEncrypted {
@@ -155,18 +158,17 @@ class NCCollectionCommon: NSObject {
                 
                 if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
                     cell.imageItem.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
-                } else if(!metadata.hasPreview) {
-                    if metadata.iconName.count > 0 {
-                        cell.imageItem.image = UIImage.init(named: metadata.iconName)
+                } else {
+                    if metadata.hasPreview {
+                        cell.imageItem.backgroundColor = .lightGray
                     } else {
-                        cell.imageItem.image = UIImage.init(named: "file")
+                        if metadata.iconName.count > 0 {
+                            cell.imageItem.image = UIImage.init(named: metadata.iconName)
+                        } else {
+                            cell.imageItem.image = UIImage.init(named: "file")
+                        }
                     }
                 }
-                if cell.imageItem.image == nil {
-                    cell.imageItem.backgroundColor = .lightGray
-                } else {
-                    cell.imageItem.backgroundColor = nil
-                }
                 
                 cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
                 
@@ -265,6 +267,9 @@ class NCCollectionCommon: NSObject {
             cell.imageLocal.image = nil
             cell.imageFavorite.image = nil
             
+            cell.imageItem.image = nil
+            cell.imageItem.backgroundColor = nil
+            
             if metadata.directory {
                 
                 if metadata.e2eEncrypted {
@@ -297,18 +302,17 @@ class NCCollectionCommon: NSObject {
                 
                 if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
                     cell.imageItem.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
-                } else if(!metadata.hasPreview) {
-                    if metadata.iconName.count > 0 {
-                        cell.imageItem.image = UIImage.init(named: metadata.iconName)
+                } else {
+                    if metadata.hasPreview {
+                        cell.imageItem.backgroundColor = .lightGray
                     } else {
-                        cell.imageItem.image = UIImage.init(named: "file")
+                        if metadata.iconName.count > 0 {
+                            cell.imageItem.image = UIImage.init(named: metadata.iconName)
+                        } else {
+                            cell.imageItem.image = UIImage.init(named: "file")
+                        }
                     }
                 }
-                if cell.imageItem.image == nil {
-                    cell.imageItem.backgroundColor = .lightGray
-                } else {
-                    cell.imageItem.backgroundColor = nil
-                }
                 
                 // image Local
                 let tableLocalFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))