marinofaggiana 5 лет назад
Родитель
Сommit
16429fe63e
2 измененных файлов с 26 добавлено и 28 удалено
  1. 21 23
      iOSClient/Main/NCDetailViewController.swift
  2. 5 5
      iOSClient/Media/NCMedia.swift

+ 21 - 23
iOSClient/Main/NCDetailViewController.swift

@@ -215,7 +215,26 @@ class NCDetailViewController: UIViewController {
     }
     
     @objc func synchronizationMedia(_ notification: NSNotification) {
-        viewImage()
+        if let userInfo = notification.userInfo as NSDictionary? {
+            if let metadata = userInfo["metadata"] as? tableMetadata, let type = userInfo["type"] as? String {
+                
+                if type == "delete" {
+                    if viewerImageViewController != nil && self.mediaFilterImage {
+                        if let metadatas = appDelegate.activeMedia.sectionDatasource.metadatas as? [tableMetadata]  {
+                            
+                            self.metadatas = metadatas
+                            var index = viewerImageViewController!.index - 1
+                            if index < 0 { index = 0}
+                            self.metadata = metadatas[index]
+                            viewImage()
+
+                        } else {
+                            viewUnload()
+                        }
+                    }
+                }
+            }
+        }
     }
     
     @objc func downloadFile(_ notification: NSNotification) {
@@ -249,28 +268,7 @@ class NCDetailViewController: UIViewController {
     @objc func deleteFile(_ notification: NSNotification) {
         if let userInfo = notification.userInfo as NSDictionary? {
             if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
-                
-                if errorCode != 0 { return }
-                
-                // IMAGE
-                if viewerImageViewController != nil && metadata.account == self.metadata?.account && metadata.serverUrl == self.metadata?.serverUrl && metadata.typeFile == k_metadataTypeFile_image {
-                        
-                    if let metadatas = NCViewerImageCommon.shared.getMetadatasDatasource(metadata: self.metadata, metadatas: self.metadatas, favoriteDatasorce: favoriteFilterImage, mediaDatasorce: mediaFilterImage, offLineDatasource: offlineFilterImage) {
-                                
-                        var index = viewerImageViewController!.index - 1
-                        if index < 0 { index = 0}
-                        self.metadata = metadatas[index]
-                        
-                        viewImage()
-                                                
-                    } else {
-                     
-                        viewUnload()
-                    }
-                    
-                // OTHER SINGLE FILE TYPE
-                } else if metadata.ocId == self.metadata?.ocId {
-                    
+                if errorCode == 0 && metadata.ocId == self.metadata?.ocId && viewerImageViewController == nil {
                     viewUnload()
                 }
             }

+ 5 - 5
iOSClient/Media/NCMedia.swift

@@ -31,16 +31,15 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-   
+    var sectionDatasource = CCSectionDataSourceMetadata()
+
     private var metadataPush: tableMetadata?
     private var isEditMode = false
     private var selectocId = [String]()
     
     private var filterTypeFileImage = false;
     private var filterTypeFileVideo = false;
-    
-    private var sectionDatasource = CCSectionDataSourceMetadata()
-    
+        
     private var autoUploadFileName = ""
     private var autoUploadDirectory = ""
     
@@ -163,7 +162,8 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
                 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])
+                let userInfo: [String : Any] = ["metadata": metadata, "type": "delete"]
+                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_synchronizationMedia), object: nil, userInfo: userInfo)
             }
         }
     }