|
@@ -941,7 +941,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
searchResults: self.searchResults)
|
|
|
} update: { _, _, searchResult, metadatas in
|
|
|
guard let metadatas, !metadatas.isEmpty, self.isSearchingMode, let searchResult else { return }
|
|
|
- NCOperationQueue.shared.unifiedSearchAddSection(collectionViewCommon: self, metadatas: metadatas, searchResult: searchResult)
|
|
|
+ self.appDelegate.unifiedSearchQueue.addOperation(NCOperationUnifiedSearch(collectionViewCommon: self, metadatas: metadatas, searchResult: searchResult))
|
|
|
} completion: { _, _ in
|
|
|
self.refreshControl.endRefreshing()
|
|
|
self.isReloadDataSourceNetworkInProgress = false
|
|
@@ -1706,6 +1706,41 @@ extension NCCollectionViewCommon: EasyTipViewDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// MARK: -
|
|
|
+
|
|
|
+class NCOperationUnifiedSearch: ConcurrentOperation {
|
|
|
+
|
|
|
+ var collectionViewCommon: NCCollectionViewCommon
|
|
|
+ var metadatas: [tableMetadata]
|
|
|
+ var searchResult: NKSearchResult
|
|
|
+
|
|
|
+ init(collectionViewCommon: NCCollectionViewCommon, metadatas: [tableMetadata], searchResult: NKSearchResult) {
|
|
|
+ self.collectionViewCommon = collectionViewCommon
|
|
|
+ self.metadatas = metadatas
|
|
|
+ self.searchResult = searchResult
|
|
|
+ }
|
|
|
+
|
|
|
+ func reloadDataThenPerform(_ closure: @escaping (() -> Void)) {
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
|
+ CATransaction.begin()
|
|
|
+ CATransaction.setCompletionBlock(closure)
|
|
|
+ self.collectionViewCommon.collectionView.reloadData()
|
|
|
+ CATransaction.commit()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override func start() {
|
|
|
+
|
|
|
+ guard !isCancelled else { return self.finish() }
|
|
|
+
|
|
|
+ self.collectionViewCommon.dataSource.addSection(metadatas: metadatas, searchResult: searchResult)
|
|
|
+ self.collectionViewCommon.searchResults?.append(self.searchResult)
|
|
|
+ reloadDataThenPerform {
|
|
|
+ self.finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
class NCCollectionViewDownloadThumbnail: ConcurrentOperation {
|
|
|
|
|
|
var metadata: tableMetadata
|