|
@@ -28,6 +28,7 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
|
|
|
internal var isRoot: Bool = true
|
|
|
internal var fileNameBlink: String?
|
|
|
+ internal var fileNameOpen: String?
|
|
|
|
|
|
// MARK: - View Life Cycle
|
|
|
|
|
@@ -60,6 +61,7 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
super.viewWillDisappear(animated)
|
|
|
|
|
|
fileNameBlink = nil
|
|
|
+ fileNameOpen = nil
|
|
|
}
|
|
|
|
|
|
// MARK: - NotificationCenter
|
|
@@ -101,7 +103,7 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
self.richWorkspaceText = directory?.richWorkspace
|
|
|
|
|
|
// FORCED false: test the directory.etag
|
|
|
- if !forced, let directory = directory, directory.etag == self.dataSource.directory?.etag, metadataTransfer == nil, self.fileNameBlink == nil {
|
|
|
+ if !forced, let directory = directory, directory.etag == self.dataSource.directory?.etag, metadataTransfer == nil, self.fileNameBlink == nil, self.fileNameOpen == nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -122,7 +124,9 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
self.collectionView.reloadData()
|
|
|
if !self.dataSource.metadatas.isEmpty {
|
|
|
self.blinkCell(fileName: self.fileNameBlink)
|
|
|
+ self.openFile(fileName: self.fileNameOpen)
|
|
|
self.fileNameBlink = nil
|
|
|
+ self.fileNameOpen = nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -139,10 +143,8 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
|
|
|
networkReadFolder(forced: forced) { tableDirectory, metadatas, metadatasUpdate, metadatasDelete, error in
|
|
|
if error == .success {
|
|
|
- for metadata in metadatas ?? [] {
|
|
|
- if !metadata.directory, NCManageDatabase.shared.isDownloadMetadata(metadata, download: false) {
|
|
|
- NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorDownloadFile)
|
|
|
- }
|
|
|
+ for metadata in metadatas ?? [] where !metadata.directory && NCManageDatabase.shared.isDownloadMetadata(metadata, download: false) {
|
|
|
+ NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorDownloadFile)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -164,7 +166,7 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
if let fileName = fileName, let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@", self.appDelegate.account, self.serverUrl, fileName)) {
|
|
|
let (indexPath, _) = self.dataSource.getIndexPathMetadata(ocId: metadata.ocId)
|
|
|
if let indexPath = indexPath {
|
|
|
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
|
UIView.animate(withDuration: 0.3) {
|
|
|
self.collectionView.scrollToItem(at: indexPath, at: .centeredVertically, animated: false)
|
|
|
} completion: { _ in
|
|
@@ -179,4 +181,16 @@ class NCFiles: NCCollectionViewCommon {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func openFile(fileName: String?) {
|
|
|
+
|
|
|
+ if let fileName = fileName, let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@", self.appDelegate.account, self.serverUrl, fileName)) {
|
|
|
+ let (indexPath, _) = self.dataSource.getIndexPathMetadata(ocId: metadata.ocId)
|
|
|
+ if let indexPath = indexPath {
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
|
+ self.collectionView(self.collectionView, didSelectItemAt: indexPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|