marinofaggiana 6 years ago
parent
commit
d367d10f7c
2 changed files with 26 additions and 28 deletions
  1. 2 2
      iOSClient/Main/CCMain.m
  2. 24 26
      iOSClient/Main/NCMainCommon.swift

+ 2 - 2
iOSClient/Main/CCMain.m

@@ -3941,8 +3941,8 @@
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
-    
-    if (metadata == nil) {
+
+    if (metadata == nil || [[NCManageDatabase sharedInstance] isTableInvalidated:metadata] || (_metadataFolder != nil && [[NCManageDatabase sharedInstance] isTableInvalidated:_metadataFolder])) {
         return [CCCellMain new];
     }
     

+ 24 - 26
iOSClient/Main/NCMainCommon.swift

@@ -1272,40 +1272,38 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
     
     @objc func downloadThumbnail(with metadata: tableMetadata, view: Any, indexPath: IndexPath) {
         
-        if metadata.hasPreview == 1 && (!CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
+        if !metadata.isInvalidated && metadata.hasPreview == 1 && (!CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
             
             let width = NCUtility.sharedInstance.getScreenWidthForPreview()
             let height = NCUtility.sharedInstance.getScreenHeightForPreview()
             
             OCNetworking.sharedManager().downloadPreview(withAccount: appDelegate.activeAccount, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, image, message, errorCode) in
                 
-                if errorCode == 0 && account == self.appDelegate.activeAccount {
-                    if CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
-                        
-                        if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                            if let cell = (view as! UICollectionView).cellForItem(at: indexPath) {
-                                if cell is NCListCell {
-                                    (cell as! NCListCell).imageItem.image = image
-                                    (cell as! NCListCell).imageItem.contentMode = .scaleAspectFill
-                                } else if cell is NCGridCell {
-                                    (cell as! NCGridCell).imageItem.image = image
-                                    (cell as! NCGridCell).imageItem.contentMode = .scaleAspectFill
-                                } else if cell is NCGridMediaCell {
-                                    (cell as! NCGridMediaCell).imageItem.image = image
-                                    (cell as! NCGridMediaCell).imageItem.contentMode = .scaleAspectFill
-                                }
+                if errorCode == 0 && account == self.appDelegate.activeAccount && !metadata.isInvalidated && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
+                    
+                    if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                        if let cell = (view as! UICollectionView).cellForItem(at: indexPath) {
+                            if cell is NCListCell {
+                                (cell as! NCListCell).imageItem.image = image
+                                (cell as! NCListCell).imageItem.contentMode = .scaleAspectFill
+                            } else if cell is NCGridCell {
+                                (cell as! NCGridCell).imageItem.image = image
+                                (cell as! NCGridCell).imageItem.contentMode = .scaleAspectFill
+                            } else if cell is NCGridMediaCell {
+                                (cell as! NCGridMediaCell).imageItem.image = image
+                                (cell as! NCGridMediaCell).imageItem.contentMode = .scaleAspectFill
                             }
                         }
-                        
-                        if view is UITableView && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                            if let cell = (view as! UITableView).cellForRow(at: indexPath) {
-                                if cell is CCCellMainTransfer {
-                                    (cell as! CCCellMainTransfer).file.image = image
-                                    (cell as! CCCellMainTransfer).file.contentMode = .scaleAspectFill
-                                } else if cell is CCCellMain {
-                                    (cell as! CCCellMain).file.image = image
-                                    (cell as! CCCellMain).file.contentMode = .scaleAspectFill
-                                }
+                    }
+                    
+                    if view is UITableView && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                        if let cell = (view as! UITableView).cellForRow(at: indexPath) {
+                            if cell is CCCellMainTransfer {
+                                (cell as! CCCellMainTransfer).file.image = image
+                                (cell as! CCCellMainTransfer).file.contentMode = .scaleAspectFill
+                            } else if cell is CCCellMain {
+                                (cell as! CCCellMain).file.image = image
+                                (cell as! CCCellMain).file.contentMode = .scaleAspectFill
                             }
                         }
                     }