|
@@ -279,20 +279,21 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let metadata = userInfo["metadata"] as? tableMetadata, let onlyLocal = userInfo["onlyLocal"] as? Bool {
|
|
|
-
|
|
|
- if onlyLocal {
|
|
|
- reloadDataSource()
|
|
|
- } else if metadata.fileNameView.lowercased() == k_fileNameRichWorkspace.lowercased() {
|
|
|
- reloadDataSourceNetwork(forced: true)
|
|
|
- } else {
|
|
|
- if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
|
|
|
- let indexPath = IndexPath(row: row, section: 0)
|
|
|
- collectionView?.performBatchUpdates({
|
|
|
- collectionView?.deleteItems(at: [indexPath])
|
|
|
- }, completion: { (_) in
|
|
|
- self.collectionView?.reloadData()
|
|
|
- })
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let onlyLocal = userInfo["onlyLocal"] as? Bool {
|
|
|
+ if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if onlyLocal {
|
|
|
+ reloadDataSource()
|
|
|
+ } else if metadata.fileNameView.lowercased() == k_fileNameRichWorkspace.lowercased() {
|
|
|
+ reloadDataSourceNetwork(forced: true)
|
|
|
+ } else {
|
|
|
+ if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
|
|
|
+ let indexPath = IndexPath(row: row, section: 0)
|
|
|
+ collectionView?.performBatchUpdates({
|
|
|
+ collectionView?.deleteItems(at: [indexPath])
|
|
|
+ }, completion: { (_) in
|
|
|
+ self.collectionView?.reloadData()
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -303,25 +304,26 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let metadata = userInfo["metadata"] as? tableMetadata, let metadataNew = userInfo["metadataNew"] as? tableMetadata {
|
|
|
-
|
|
|
- if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
- if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
|
|
|
- let indexPath = IndexPath(row: row, section: 0)
|
|
|
- collectionView?.performBatchUpdates({
|
|
|
- collectionView?.deleteItems(at: [indexPath])
|
|
|
- }, completion: { (_) in
|
|
|
- self.collectionView?.reloadData()
|
|
|
- })
|
|
|
- }
|
|
|
- } else if metadataNew.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
- if let row = dataSource.addMetadata(metadataNew) {
|
|
|
- let indexPath = IndexPath(row: row, section: 0)
|
|
|
- collectionView?.performBatchUpdates({
|
|
|
- collectionView?.insertItems(at: [indexPath])
|
|
|
- }, completion: { (_) in
|
|
|
- self.collectionView?.reloadData()
|
|
|
- })
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let ocIdNew = userInfo["ocIdNew"] as? String {
|
|
|
+ if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId), let metadataNew = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocIdNew) {
|
|
|
+ if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
+ if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
|
|
|
+ let indexPath = IndexPath(row: row, section: 0)
|
|
|
+ collectionView?.performBatchUpdates({
|
|
|
+ collectionView?.deleteItems(at: [indexPath])
|
|
|
+ }, completion: { (_) in
|
|
|
+ self.collectionView?.reloadData()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if metadataNew.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
+ if let row = dataSource.addMetadata(metadataNew) {
|
|
|
+ let indexPath = IndexPath(row: row, section: 0)
|
|
|
+ collectionView?.performBatchUpdates({
|
|
|
+ collectionView?.insertItems(at: [indexPath])
|
|
|
+ }, completion: { (_) in
|
|
|
+ self.collectionView?.reloadData()
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -350,15 +352,17 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let metadata = userInfo["metadata"] as? tableMetadata {
|
|
|
- if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
- if let row = dataSource.addMetadata(metadata) {
|
|
|
- let indexPath = IndexPath(row: row, section: 0)
|
|
|
- collectionView?.performBatchUpdates({
|
|
|
- collectionView?.insertItems(at: [indexPath])
|
|
|
- }, completion: { (_) in
|
|
|
- self.collectionView?.reloadData()
|
|
|
- })
|
|
|
+ if let ocId = userInfo["ocId"] as? String {
|
|
|
+ if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
+ if let row = dataSource.addMetadata(metadata) {
|
|
|
+ let indexPath = IndexPath(row: row, section: 0)
|
|
|
+ collectionView?.performBatchUpdates({
|
|
|
+ collectionView?.insertItems(at: [indexPath])
|
|
|
+ }, completion: { (_) in
|
|
|
+ self.collectionView?.reloadData()
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -371,7 +375,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let metadata = userInfo["metadata"] as? tableMetadata {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
if dataSource.getIndexMetadata(ocId: metadata.ocId) != nil {
|
|
|
reloadDataSource()
|
|
|
}
|