Browse Source

Merge pull request #2426 from nextcloud/improvement/delete

Improvement/delete
Marino Faggiana 2 years ago
parent
commit
a2da66f280

+ 3 - 3
Nextcloud.xcodeproj/project.pbxproj

@@ -3958,7 +3958,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 20;
+				CURRENT_PROJECT_VERSION = 21;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -4021,7 +4021,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 20;
+				CURRENT_PROJECT_VERSION = 21;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -4276,7 +4276,7 @@
 			repositoryURL = "https://github.com/nextcloud/NextcloudKit";
 			requirement = {
 				kind = exactVersion;
-				version = 2.3.0;
+				version = 2.4.0;
 			};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

+ 5 - 54
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -353,57 +353,22 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     @objc func deleteFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
-              let ocId = userInfo["ocId"] as? String,
-              let fileNameView = userInfo["fileNameView"] as? String,
-              let serverUrl = userInfo["serverUrl"] as? String,
-              serverUrl == self.serverUrl,
-              let account = userInfo["account"] as? String,
-              account == appDelegate.account,
-              let onlyLocalCache = userInfo["onlyLocalCache"] as? Bool
+              let error = userInfo["error"] as? NKError
         else { return }
 
-        if fileNameView.lowercased() == NCGlobal.shared.fileNameRichWorkspace.lowercased() {
-            reloadDataSourceNetwork(forced: true)
-        } else if onlyLocalCache {
-            self.collectionView?.reloadData()
-        } else {
-            let (indexPath, sameSections) = dataSource.deleteMetadata(ocId: ocId)
-            if let indexPath = indexPath, dataSource.metadatas.count > 0, sameSections {
-                collectionView?.performBatchUpdates({
-                    if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
-                        collectionView?.deleteItems(at: [indexPath])
-                    }
-                }, completion: { _ in
-                    self.collectionView?.reloadData()
-                })
-            } else {
-                reloadDataSource()
-            }
+        if error == .success {
+            reloadDataSource()
         }
     }
 
     @objc func moveFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
-              let ocId = userInfo["ocId"] as? String,
               let serverUrlFrom = userInfo["serverUrlFrom"] as? String,
               serverUrlFrom == self.serverUrl
         else { return }
 
-        let (indexPath, sameSections) = dataSource.deleteMetadata(ocId: ocId)
-        if let indexPath = indexPath {
-            if sameSections && (indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section)) {
-                collectionView?.performBatchUpdates({
-                    collectionView?.deleteItems(at: [indexPath])
-                }, completion: { _ in
-                    self.collectionView?.reloadData()
-                })
-            } else {
-                self.collectionView?.reloadData()
-            }
-        } else {
-            reloadDataSource()
-        }
+        reloadDataSource()
     }
 
     @objc func copyFile(_ notification: NSNotification) {
@@ -581,27 +546,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     @objc func uploadCancelFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
-              let ocId = userInfo["ocId"] as? String,
               let serverUrl = userInfo["serverUrl"] as? String,
               serverUrl == self.serverUrl,
               let account = userInfo["account"] as? String,
               account == appDelegate.account
         else { return }
 
-        let (indexPath, sameSections) = dataSource.deleteMetadata(ocId: ocId)
-        if let indexPath = indexPath {
-            if sameSections && (indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section)) {
-                collectionView?.performBatchUpdates({
-                    collectionView?.deleteItems(at: [indexPath])
-                }, completion: { _ in
-                    self.collectionView?.reloadData()
-                })
-            } else {
-                self.collectionView?.reloadData()
-            }
-        } else {
-            reloadDataSource()
-        }
+        reloadDataSource()
     }
 
     @objc func triggerProgressTask(_ notification: NSNotification) {

+ 1 - 1
iOSClient/Main/NCActionCenter.swift

@@ -492,7 +492,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                     let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId!, fileNameView: fileName)!
                     NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: toPath)
                     NCManageDatabase.shared.addLocalFile(account: account, etag: etag!, ocId: ocId!, fileName: fileName)
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced, userInfo: ["serverUrl": serverUrl])
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
                 } else if afError?.isExplicitlyCancelledError ?? false {
                     print("cancel")
                 } else {

+ 18 - 11
iOSClient/Media/NCMedia.swift

@@ -170,20 +170,27 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
     @objc func deleteFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
-              let ocId = userInfo["ocId"] as? String
+              let ocIds = userInfo["ocId"] as? [String],
+              let error = userInfo["error"] as? NKError
         else { return }
 
-        let indexes = self.metadatas.indices.filter { self.metadatas[$0].ocId == ocId }
-        let metadatas = self.metadatas.filter { $0.ocId != 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])
+        if error == .success {
+            var items: [IndexPath] = []
+            var index: Int = 0
+            for metadata in metadatas {
+                if ocIds.contains(metadata.ocId) {
+                    self.metadatas.remove(at: index)
+                    items.append(IndexPath(row: index, section: 0))
+                }
+                if ocIds.count == items.count { break }
+                index += 1
+            }
+            if ocIds.count == items.count {
+                self.collectionView?.deleteItems(at: items)
+            } else {
+                self.reloadDataSourceWithCompletion { _ in }
+            }
         }
-
         self.updateMediaControlVisibility()
     }
 

+ 17 - 3
iOSClient/Menu/NCContextMenu.swift

@@ -153,10 +153,15 @@ class NCContextMenu: NSObject {
                                          image: UIImage(systemName: "trash"), attributes: .destructive) { _ in
             let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_delete_file_", comment: ""), style: .destructive) { _ in
-                NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: false) { error in
-                    if error != .success {
+                Task {
+                    var ocId: [String] = []
+                    let error = await NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: false)
+                    if error == .success {
+                        ocId.append(metadata.ocId)
+                    } else {
                         NCContentPresenter.shared.showError(error: error)
                     }
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDeleteFile, userInfo: ["ocId": ocId, "error": error])
                 }
             })
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { _ in })
@@ -165,7 +170,16 @@ class NCContextMenu: NSObject {
 
         let deleteConfirmLocal = UIAction(title: NSLocalizedString("_remove_local_file_", comment: ""),
                                           image: UIImage(systemName: "trash"), attributes: .destructive) { _ in
-            NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: true) { _ in }
+            Task {
+                var ocId: [String] = []
+                let error = await NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: true)
+                if error == .success {
+                    ocId.append(metadata.ocId)
+                } else {
+                    NCContentPresenter.shared.showError(error: error)
+                }
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDeleteFile, userInfo: ["ocId": ocId, "error": error])
+            }
         }
 
         let deleteSubMenu = UIMenu(title: NSLocalizedString("_delete_file_", comment: ""),

+ 28 - 2
iOSClient/Menu/NCMenuAction.swift

@@ -136,7 +136,20 @@ extension NCMenuAction {
                     preferredStyle: .alert)
                 if canDeleteServer {
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_delete_", comment: ""), style: .default) { (_: UIAlertAction) in
-                        selectedMetadatas.forEach({ NCOperationQueue.shared.delete(metadata: $0, onlyLocalCache: false) })
+                        Task {
+                            var error = NKError()
+                            var ocId: [String] = []
+                            for metadata in selectedMetadatas where error == .success {
+                                error = await NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: false)
+                                if error == .success {
+                                    ocId.append(metadata.ocId)
+                                }
+                            }
+                            if error != .success {
+                                NCContentPresenter.shared.showError(error: error)
+                            }
+                            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDeleteFile, userInfo: ["ocId": ocId, "error": error])
+                        }
                         completion?()
                     })
                 }
@@ -144,7 +157,20 @@ extension NCMenuAction {
                 // NCMedia removes image from collection view if removed from cache
                 if !(viewController is NCMedia) {
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_local_file_", comment: ""), style: .default) { (_: UIAlertAction) in
-                        selectedMetadatas.forEach({ NCOperationQueue.shared.delete(metadata: $0, onlyLocalCache: true) })
+                        Task {
+                            var error = NKError()
+                            var ocId: [String] = []
+                            for metadata in selectedMetadatas where error == .success {
+                                error = await NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: true)
+                                if error == .success {
+                                    ocId.append(metadata.ocId)
+                                }
+                            }
+                            if error != .success {
+                                NCContentPresenter.shared.showError(error: error)
+                            }
+                            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDeleteFile, userInfo: ["ocId": ocId, "error": error])
+                        }
                         completion?()
                     })
                 }

+ 2 - 2
iOSClient/NCGlobal.swift

@@ -328,7 +328,7 @@ class NCGlobal: NSObject {
 
     @objc let notificationCenterReloadDataSource                = "reloadDataSource"                // userInfo: serverUrl?
     let notificationCenterReloadDataSourceNetwork               = "reloadDataSourceNetwork"         // userInfo: serverUrl?
-    let notificationCenterReloadDataSourceNetworkForced         = "reloadDataSourceNetworkForced"   // userInfo: serverUrl?
+    let notificationCenterReloadDataSourceNetworkForced         = "reloadDataSourceNetworkForced"
 
     let notificationCenterChangeStatusFolderE2EE                = "changeStatusFolderE2EE"          // userInfo: serverUrl
 
@@ -343,7 +343,7 @@ class NCGlobal: NSObject {
     let notificationCenterProgressTask                          = "progressTask"                    // userInfo: account, ocId, serverUrl, status, progress, totalBytes, totalBytesExpected
 
     let notificationCenterCreateFolder                          = "createFolder"                    // userInfo: ocId, serverUrl, account, e2ee, withPush
-    let notificationCenterDeleteFile                            = "deleteFile"                      // userInfo: ocId, fileNameView, serverUrl, account, classFile, onlyLocalCache
+    let notificationCenterDeleteFile                            = "deleteFile"                      // userInfo: ocIds, error
     let notificationCenterRenameFile                            = "renameFile"                      // userInfo: ocId, account
     let notificationCenterMoveFile                              = "moveFile"                        // userInfo: ocId, account, serverUrlFrom
     let notificationCenterCopyFile                              = "copyFile"                        // userInfo: ocId, serverUrlTo

+ 28 - 44
iOSClient/Networking/NCNetworking.swift

@@ -1159,7 +1159,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
     // MARK: - WebDav Delete
 
-    func deleteMetadata(_ metadata: tableMetadata, onlyLocalCache: Bool, completion: @escaping (_ error: NKError) -> Void) {
+    func deleteMetadata(_ metadata: tableMetadata, onlyLocalCache: Bool) async -> (NKError) {
 
         if onlyLocalCache {
 
@@ -1180,10 +1180,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
                     NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadataLivePhoto.ocId))
                     NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId))
                 }
-
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDeleteFile, userInfo: ["ocId": metadata.ocId, "fileNameView": metadata.fileNameView, "serverUrl": metadata.serverUrl, "account": metadata.account, "classFile": metadata.classFile, "onlyLocalCache": true])
             }
-            return completion(NKError())
+            return NKError()
         }
 
         let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
@@ -1194,73 +1192,59 @@ class NCNetworking: NSObject, NKCommonDelegate {
                 if let metadataLive = metadataLive {
                     let error = await NCNetworkingE2EEDelete.shared.delete(metadata: metadataLive)
                     if error == .success {
-                        let error = await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
-                        completion(error)
+                        return await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
                     } else {
-                        completion(error)
+                        return error
                     }
                 } else {
-                    let error = await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
-                    completion(error)
+                    return await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
                 }
             }
 #endif
         } else {
-            if metadataLive == nil {
-                self.deleteMetadataPlain(metadata, customHeader: nil, completion: completion)
-            } else {
-                self.deleteMetadataPlain(metadataLive!, customHeader: nil) { error in
-                    if error == .success {
-                        self.deleteMetadataPlain(metadata, customHeader: nil, completion: completion)
-                    } else {
-                        completion(error)
-                    }
+            if let metadataLive = metadataLive {
+                let error = await deleteMetadataPlain(metadataLive)
+                if error == .success {
+                    return await deleteMetadataPlain(metadata)
+                } else {
+                    return error
                 }
+            } else {
+                return await deleteMetadataPlain(metadata)
             }
         }
+        return NKError()
     }
 
-    func deleteMetadataPlain(_ metadata: tableMetadata, customHeader: [String: String]?, completion: @escaping (_ error: NKError) -> Void) {
+    func deleteMetadataPlain(_ metadata: tableMetadata, customHeader: [String: String]? = nil) async -> (NKError) {
 
         // verify permission
         let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCGlobal.shared.permissionCanDelete)
         if metadata.permissions != "" && permission == false {
-            return completion(NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_delete_file_"))
+            return NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_delete_file_")
         }
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         let options = NKRequestOptions(customHeader: customHeader)
-        
-        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, options: options) { account, error in
 
-            if error == .success || error.errorCode == NCGlobal.shared.errorResourceNotFound {
+        let result = await NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, options: options)
 
-                do {
-                    try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
-                } catch { }
+        if result.error == .success || result.error.errorCode == NCGlobal.shared.errorResourceNotFound {
 
-                NCManageDatabase.shared.deleteVideo(metadata: metadata)
-                NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+            do {
+                try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+            } catch { }
 
-                if metadata.directory {
-                    NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
-                }
+            NCManageDatabase.shared.deleteVideo(metadata: metadata)
+            NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+            NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
 
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDeleteFile, userInfo: ["ocId": metadata.ocId, "fileNameView": metadata.fileNameView, "serverUrl": metadata.serverUrl, "account": metadata.account, "classFile": metadata.classFile, "onlyLocalCache": false])
+            if metadata.directory {
+                NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
             }
-
-            completion(error)
         }
-    }
-
-    func deleteMetadataPlain(_ metadata: tableMetadata, customHeader: [String: String]?) async -> (NKError) {
 
-        await withUnsafeContinuation({ continuation in
-            self.deleteMetadataPlain(metadata, customHeader: customHeader) { error in
-                continuation.resume(returning: error)
-            }
-        })
+        return result.error
     }
 
     // MARK: - WebDav Favorite
@@ -1424,7 +1408,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
                         if let path = CCUtility.getDirectoryProviderStorageOcId(ocId) {
                             NCUtilityFileSystem.shared.deleteFile(filePath: path)
                         }
-                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced, userInfo: ["serverUrl": metadata.serverUrl])
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
 
                     } else {
 

+ 1 - 1
iOSClient/Networking/NCNetworkingChunkedUpload.swift

@@ -201,7 +201,7 @@ extension NCNetworking {
 
                     } else {
 
-                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced, userInfo: ["serverUrl": serverUrl])
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
                         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": ocIdTemp, "serverUrl": serverUrl, "account": account, "fileName": fileName, "ocIdTemp": ocIdTemp, "error": error])
                     }
 

+ 0 - 50
iOSClient/Networking/NCOperationQueue.swift

@@ -32,8 +32,6 @@ import NextcloudKit
     }()
 
     private var downloadQueue = Queuer(name: "downloadQueue", maxConcurrentOperationCount: 5, qualityOfService: .default)
-    private let deleteQueue = Queuer(name: "deleteQueue", maxConcurrentOperationCount: 10, qualityOfService: .default)
-    private let deleteQueueE2EE = Queuer(name: "deleteQueue", maxConcurrentOperationCount: 1, qualityOfService: .default)
     private let copyMoveQueue = Queuer(name: "copyMoveQueue", maxConcurrentOperationCount: 1, qualityOfService: .default)
     private let synchronizationQueue = Queuer(name: "synchronizationQueue", maxConcurrentOperationCount: 1, qualityOfService: .default)
     private let downloadThumbnailQueue = Queuer(name: "downloadThumbnailQueue", maxConcurrentOperationCount: 10, qualityOfService: .default)
@@ -44,7 +42,6 @@ import NextcloudKit
 
     @objc func cancelAllQueue() {
         downloadCancelAll()
-        deleteCancelAll()
         copyMoveCancelAll()
         synchronizationCancelAll()
         downloadThumbnailCancelAll()
@@ -78,27 +75,6 @@ import NextcloudKit
         return false
     }
 
-    // MARK: - Delete file
-
-    func delete(metadata: tableMetadata, onlyLocalCache: Bool) {
-
-        if metadata.isDirectoryE2EE {
-            for case let operation as NCOperationDelete in deleteQueueE2EE.operations where operation.metadata.ocId == metadata.ocId {
-                return
-            }
-            deleteQueueE2EE.addOperation(NCOperationDelete(metadata: metadata, onlyLocalCache: onlyLocalCache))
-        } else {
-            for case let operation as NCOperationDelete in deleteQueue.operations where operation.metadata.ocId == metadata.ocId {
-                return
-            }
-            deleteQueue.addOperation(NCOperationDelete(metadata: metadata, onlyLocalCache: onlyLocalCache))
-        }
-    }
-
-    func deleteCancelAll() {
-        deleteQueue.cancelAll()
-    }
-
     // MARK: - Copy Move file
 
     func copyMove(metadata: tableMetadata, serverUrl: String, overwrite: Bool, move: Bool) {
@@ -268,32 +244,6 @@ class NCOperationDownload: ConcurrentOperation {
 
 // MARK: -
 
-class NCOperationDelete: ConcurrentOperation {
-
-    var metadata: tableMetadata
-    var onlyLocalCache: Bool
-
-    init(metadata: tableMetadata, onlyLocalCache: Bool) {
-        self.metadata = tableMetadata.init(value: metadata)
-        self.onlyLocalCache = onlyLocalCache
-    }
-
-    override func start() {
-        if isCancelled {
-            self.finish()
-        } else {
-            NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: onlyLocalCache) { error in
-                if error != .success {
-                    NCContentPresenter.shared.showError(error: error)
-                }
-                self.finish()
-            }
-        }
-    }
-}
-
-// MARK: -
-
 class NCOperationCopyMove: ConcurrentOperation {
 
     var metadata: tableMetadata

+ 3 - 1
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -167,7 +167,9 @@ class NCViewerMedia: UIViewController {
                 }
             }
         } else if metadata.isImage {
-            showTip()
+            DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
+                self.showTip()
+            }
         }
 
         NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)

+ 14 - 11
iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift

@@ -365,20 +365,23 @@ class NCViewerMediaPage: UIViewController {
     @objc func deleteFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
-              let ocId = userInfo["ocId"] as? String
+              let ocId = userInfo["ocId"] as? [String],
+              let error = userInfo["error"] as? NKError
         else { return }
 
-        // Stop media
-        if let ncplayer = currentViewController.ncplayer, ncplayer.isPlay() {
-            ncplayer.playerPause()
-        }
-        
-        let metadatas = self.metadatas.filter { $0.ocId != ocId }
-        if self.metadatas.count == metadatas.count { return }
-        self.metadatas = metadatas
+        if error == .success, let ocId = ocId.first {
+            // Stop media
+            if let ncplayer = currentViewController.ncplayer, ncplayer.isPlay() {
+                ncplayer.playerPause()
+            }
 
-        if ocId == currentViewController.metadata.ocId {
-            shiftCurrentPage()
+            let metadatas = self.metadatas.filter { $0.ocId != ocId }
+            if self.metadatas.count == metadatas.count { return }
+            self.metadatas = metadatas
+            
+            if ocId == currentViewController.metadata.ocId {
+                shiftCurrentPage()
+            }
         }
     }
 

+ 1 - 1
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -211,7 +211,7 @@ extension NCViewerNextcloudText: UINavigationControllerDelegate {
         super.didMove(toParent: parent)
 
         if parent == nil {
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced, userInfo: ["serverUrl": self.metadata.serverUrl])
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
         }
     }
 }

+ 5 - 3
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -336,11 +336,13 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     @objc func deleteFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
-              let ocId = userInfo["ocId"] as? String,
-              ocId == self.metadata.ocId
+              let ocId = userInfo["ocId"] as? [String],
+              let error = userInfo["error"] as? NKError
         else { return }
 
-        viewUnload()
+        if error == .success, let ocId = ocId.first, metadata.ocId == ocId {
+            viewUnload()
+        }
     }
 
     @objc func renameFile(_ notification: NSNotification) {

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -352,7 +352,7 @@ extension NCViewerRichdocument: UINavigationControllerDelegate {
         super.didMove(toParent: parent)
 
         if parent == nil {
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced, userInfo: ["serverUrl": self.metadata.serverUrl])
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
         }
     }
 }