Browse Source

fix deletefile

marinofaggiana 4 years ago
parent
commit
316c89837f

+ 1 - 1
iOSClient/CCGlobal.h

@@ -332,7 +332,7 @@
 #define k_notificationCenter_progressTask                   @"progressTask"                     // userInfo: account, ocId, serverUrl, status, progress, totalBytes, totalBytesExpected
 
 #define k_notificationCenter_createFolder                   @"createFolder"                     // userInfo: ocId
-#define k_notificationCenter_deleteFile                     @"deleteFile"                       // userInfo: ocId, onlyLocal
+#define k_notificationCenter_deleteFile                     @"deleteFile"                       // userInfo: ocId, fileNameView, typeFile, onlyLocal
 #define k_notificationCenter_renameFile                     @"renameFile"                       // userInfo: ocId, errorCode, errorDescription
 #define k_notificationCenter_moveFile                       @"moveFile"                         // userInfo: ocId, metadataNew
 #define k_notificationCenter_copyFile                       @"copyFile"                         // userInfo: ocId, serverUrlTo

+ 0 - 23
iOSClient/Images.xcassets/activityHigh.imageset/Contents.json

@@ -1,23 +0,0 @@
-{
-  "images" : [
-    {
-      "idiom" : "universal",
-      "filename" : "activityHigh.png",
-      "scale" : "1x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "activityHigh@2x.png",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "activityHigh@3x.png",
-      "scale" : "3x"
-    }
-  ],
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

BIN
iOSClient/Images.xcassets/activityHigh.imageset/activityHigh.png


BIN
iOSClient/Images.xcassets/activityHigh.imageset/activityHigh@2x.png


BIN
iOSClient/Images.xcassets/activityHigh.imageset/activityHigh@3x.png


+ 0 - 23
iOSClient/Images.xcassets/filePreviewError.imageset/Contents.json

@@ -1,23 +0,0 @@
-{
-  "images" : [
-    {
-      "idiom" : "universal",
-      "scale" : "1x",
-      "filename" : "filePreviewError.png"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "filePreviewError@2x.png",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "scale" : "3x",
-      "filename" : "filePreviewError@3x.png"
-    }
-  ],
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

BIN
iOSClient/Images.xcassets/filePreviewError.imageset/filePreviewError.png


BIN
iOSClient/Images.xcassets/filePreviewError.imageset/filePreviewError@2x.png


BIN
iOSClient/Images.xcassets/filePreviewError.imageset/filePreviewError@3x.png


+ 3 - 4
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -300,14 +300,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let onlyLocal = userInfo["onlyLocal"] as? Bool, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
-                
+            if let ocId = userInfo["ocId"] as? String, let fileNameView = userInfo["fileNameView"] as? String, let onlyLocal = userInfo["onlyLocal"] as? Bool {
                 if onlyLocal {
                     reloadDataSource()
-                } else if metadata.fileNameView.lowercased() == k_fileNameRichWorkspace.lowercased() {
+                } else if fileNameView.lowercased() == k_fileNameRichWorkspace.lowercased() {
                     reloadDataSourceNetwork(forced: true)
                 } else {
-                    if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
+                    if let row = dataSource.deleteMetadata(ocId: ocId) {
                         let indexPath = IndexPath(row: row, section: 0)
                         collectionView?.performBatchUpdates({
                             collectionView?.deleteItems(at: [indexPath])

+ 12 - 15
iOSClient/Media/NCMedia.swift

@@ -405,23 +405,20 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String {
+          
+                let indexes = self.metadatas.indices.filter { self.metadatas[$0].ocId == ocId }
+                let metadatas = self.metadatas.filter { $0.ocId != ocId }
+                self.metadatas = metadatas
                 
-                if metadata.account == appDelegate.account {
-                    
-                    let indexes = self.metadatas.indices.filter { self.metadatas[$0].ocId == metadata.ocId }
-                    let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
-                    self.metadatas = metadatas
-                    
-                    if self.metadatas.count == 0 {
-                        collectionView?.reloadData()
-                    } else if let row = indexes.first {
-                        let indexPath = IndexPath(row: row, section: 0)
-                        collectionView?.deleteItems(at: [indexPath])
-                    }
-                    
-                    self.updateMediaControlVisibility()
+                if self.metadatas.count == 0 {
+                    collectionView?.reloadData()
+                } else if let row = indexes.first {
+                    let indexPath = IndexPath(row: row, section: 0)
+                    collectionView?.deleteItems(at: [indexPath])
                 }
+                
+                self.updateMediaControlVisibility()
             }
         }
     }

+ 2 - 2
iOSClient/Networking/NCNetworking.swift

@@ -909,7 +909,7 @@ import Queuer
                 NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId))
             }
             
-            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["ocId": metadata.ocId, "onlyLocal": true])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["ocId": metadata.ocId, "fileNameView": metadata.fileNameView, "typeFile": metadata.typeFile, "onlyLocal": true])
             completion(0, "")
             
             return
@@ -973,7 +973,7 @@ import Queuer
                     NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
                 }
                 
-                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["ocId": metadata.ocId, "onlyLocal": false])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["ocId": metadata.ocId, "fileNameView": metadata.fileNameView, "typeFile": metadata.typeFile, "onlyLocal": true])
             }
             
             completion(errorCode, errorDescription)

+ 3 - 3
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -172,13 +172,13 @@ class NCViewerImage: UIViewController {
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String {
                 
-                let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
+                let metadatas = self.metadatas.filter { $0.ocId != ocId }
                 if self.metadatas.count == metadatas.count { return }
                 self.metadatas = metadatas
                 
-                if metadata.ocId == currentViewerImageZoom?.metadata.ocId {
+                if ocId == currentViewerImageZoom?.metadata.ocId {
                     if !shiftCurrentPage() {
                         self.viewUnload()
                     }

+ 2 - 2
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -167,8 +167,8 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     @objc func deleteFile(_ notification: NSNotification) {
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["OcId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
-                if metadata.ocId == self.metadata.ocId {
+            if let ocId = userInfo["OcId"] as? String {
+                if ocId == self.metadata.ocId {
                     viewUnload()
                 }
             }