Эх сурвалжийг харах

Update library NCCommunication

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 жил өмнө
parent
commit
8f70a2b13a

+ 21 - 3
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -537,7 +537,16 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 if let cell = collectionView?.cellForItem(at: IndexPath(row: index, section: 0)) {
                     if cell is NCListCell {
                         let cell = cell as! NCListCell
-                        if progressNumber.floatValue > 0 {
+                        if progressNumber.floatValue == 1 {
+                            cell.progressView?.isHidden = true
+                            cell.progressView?.progress = .zero
+                            cell.setButtonMore(named: NCGlobal.shared.buttonMoreMore, image: NCBrandColor.cacheImages.buttonMore)
+                            if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                                cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
+                            } else {
+                                cell.labelInfo.text = ""
+                            }
+                        } else if progressNumber.floatValue > 0 {
                             cell.progressView?.isHidden = false
                             cell.progressView?.progress = progressNumber.floatValue
                             cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
@@ -549,7 +558,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                         }
                     } else if cell is NCTransferCell {
                         let cell = cell as! NCTransferCell
-                        if progressNumber.floatValue > 0 {
+                        if progressNumber.floatValue == 1 {
+                            cell.progressView?.isHidden = true
+                            cell.progressView?.progress = .zero
+                            cell.buttonMore.isHidden = true
+                            cell.labelInfo.text = ""
+                        } else if progressNumber.floatValue > 0 {
                             cell.progressView?.isHidden = false
                             cell.progressView?.progress = progressNumber.floatValue
                             cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
@@ -561,7 +575,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                         }
                     } else if cell is NCGridCell {
                         let cell = cell as! NCGridCell
-                        if progressNumber.floatValue > 0 {
+                        if progressNumber.floatValue == 1 {
+                            cell.progressView.isHidden = true
+                            cell.progressView.progress = .zero
+                            cell.setButtonMore(named: NCGlobal.shared.buttonMoreMore, image: NCBrandColor.cacheImages.buttonMore)
+                        } else if progressNumber.floatValue > 0 {
                             cell.progressView.isHidden = false
                             cell.progressView.progress = progressNumber.floatValue
                             cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)

+ 4 - 10
iOSClient/Networking/NCNetworking.swift

@@ -103,7 +103,6 @@ import Queuer
         
         // Notification
         NotificationCenter.default.addObserver(self, selector: #selector(downloadStartFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadStartFile), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadedFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(downloadCancelFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadCancelFile), object: nil)
         
         NotificationCenter.default.addObserver(self, selector: #selector(uploadStartFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadStartFile), object: nil)
@@ -170,15 +169,6 @@ import Queuer
     @objc func downloadStartFile(_ notification: NSNotification) {
     }
     
-    @objc func downloadedFile(_ notification: NSNotification) {
-        
-        if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String {
-            #if !EXTENSION
-            (UIApplication.shared.delegate as! AppDelegate).listProgress[ocId] = nil
-            #endif
-        }
-    }
-    
     @objc func downloadCancelFile(_ notification: NSNotification) {
         
         if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String {
@@ -447,6 +437,10 @@ import Queuer
             }
             
             self.downloadRequest[fileNameLocalPath] = nil
+            #if !EXTENSION
+            DispatchQueue.main.async { (UIApplication.shared.delegate as! AppDelegate).listProgress[metadata.ocId] = nil }
+            #endif
+            
             if error?.isExplicitlyCancelledError ?? false {
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId":metadata.ocId])
             } else {