marinofaggiana 5 жил өмнө
parent
commit
cfd0725289

+ 1 - 0
iOSClient/CCGlobal.h

@@ -324,6 +324,7 @@
 #define k_notificationCenter_initializeMain             @"initializeMain"
 #define k_notificationCenter_changeTheming              @"changeTheming"
 #define k_notificationCenter_splitViewChangeDisplayMode @"splitViewChangeDisplayMode"
+#define k_notificationCenter_synchronizationMedia       @"synchronizationMedia"
 
 #define k_notificationCenter_uploadFile                 @"uploadFile"
 #define k_notificationCenter_downloadFile               @"downloadFile"

+ 6 - 0
iOSClient/Main/NCDetailViewController.swift

@@ -58,6 +58,8 @@ class NCDetailViewController: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeDisplayMode), name: NSNotification.Name(rawValue: k_notificationCenter_splitViewChangeDisplayMode), object: nil)
         
+        NotificationCenter.default.addObserver(self, selector: #selector(self.synchronizationMedia(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_synchronizationMedia), object: nil)
+        
         NotificationCenter.default.addObserver(self, selector: #selector(self.downloadFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_downloadFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(self.deleteFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_deleteFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(self.uploadFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_uploadFile), object: nil)
@@ -212,6 +214,10 @@ class NCDetailViewController: UIViewController {
         }
     }
     
+    @objc func synchronizationMedia(_ notification: NSNotification) {
+        viewImage()
+    }
+    
     @objc func downloadFile(_ notification: NSNotification) {
         if let userInfo = notification.userInfo as NSDictionary? {
             if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {

+ 6 - 1
iOSClient/Media/NCMedia.swift

@@ -156,9 +156,14 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
 
     @objc func deleteFile(_ notification: NSNotification) {
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let metadata = userInfo["metadata"] as? tableMetadata {
+            if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
+                
+                if errorCode != 0 { return }
+
                 self.selectocId.removeAll { $0 == metadata.ocId }
                 self.reloadDataSource(loadNetworkDatasource: false)
+                
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_synchronizationMedia), object: nil, userInfo: userInfo as? [AnyHashable : Any])
             }
         }
     }