|
@@ -277,14 +277,13 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
|
|
|
if metadata.account == appDelegate.activeAccount {
|
|
|
let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
|
|
|
self.metadatas = metadatas
|
|
|
-
|
|
|
self.updateMediaControlVisibility()
|
|
|
-
|
|
|
- self.reloadDataSource()
|
|
|
+ self.reloadDataSourceWithCompletion() {
|
|
|
|
|
|
- if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
|
|
|
- let userInfo: [String : Any] = ["metadata": metadata, "type": "delete"]
|
|
|
- NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
|
|
|
+ if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
|
|
|
+ let userInfo: [String : Any] = ["metadata": metadata, "type": "delete"]
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -295,11 +294,12 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
if let metadata = userInfo["metadata"] as? tableMetadata, let metadataNew = userInfo["metadataNew"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
|
|
|
if metadata.account == appDelegate.activeAccount {
|
|
|
- self.reloadDataSource()
|
|
|
+ self.reloadDataSourceWithCompletion() {
|
|
|
|
|
|
- if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
|
|
|
- let userInfo: [String : Any] = ["metadata": metadata, "metadataNew": metadataNew, "type": "move"]
|
|
|
- NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
|
|
|
+ if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
|
|
|
+ let userInfo: [String : Any] = ["metadata": metadata, "metadataNew": metadataNew, "type": "move"]
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -310,11 +310,12 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
|
|
|
if metadata.account == appDelegate.activeAccount {
|
|
|
- self.reloadDataSource()
|
|
|
+ self.reloadDataSourceWithCompletion() {
|
|
|
|
|
|
- if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
|
|
|
- let userInfo: [String : Any] = ["metadata": metadata, "type": "rename"]
|
|
|
- NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
|
|
|
+ if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
|
|
|
+ let userInfo: [String : Any] = ["metadata": metadata, "type": "rename"]
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -522,6 +523,10 @@ extension NCMedia: UICollectionViewDelegateFlowLayout {
|
|
|
extension NCMedia {
|
|
|
|
|
|
@objc func reloadDataSource() {
|
|
|
+ self.reloadDataSourceWithCompletion { }
|
|
|
+ }
|
|
|
+
|
|
|
+ private func reloadDataSourceWithCompletion(_ completion: @escaping () -> Void) {
|
|
|
|
|
|
if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
|
|
|
return
|
|
@@ -547,6 +552,7 @@ extension NCMedia {
|
|
|
self.mediaCommandTitle()
|
|
|
}
|
|
|
}
|
|
|
+ completion()
|
|
|
}
|
|
|
}
|
|
|
|