Begin moving the MainThreadOperationQueue from Account to ArticlesDatabase.
This commit is contained in:
parent
2d33de1205
commit
d40eaed1f5
|
@ -1277,13 +1277,8 @@ private extension Account {
|
||||||
|
|
||||||
func fetchAllUnreadCounts() {
|
func fetchAllUnreadCounts() {
|
||||||
fetchingAllUnreadCounts = true
|
fetchingAllUnreadCounts = true
|
||||||
operationQueue.cancelOperations(named: OperationName.FetchAllUnreadCounts)
|
database.fetchAllUnreadCounts { (result) in
|
||||||
|
guard let unreadCountDictionary = try? result.get() else {
|
||||||
let operation = database.createFetchAllUnreadCountsOperation()
|
|
||||||
operation.name = OperationName.FetchAllUnreadCounts
|
|
||||||
operation.completionBlock = { operation in
|
|
||||||
let fetchOperation = operation as! FetchAllUnreadCountsOperation
|
|
||||||
guard let unreadCountDictionary = fetchOperation.unreadCountDictionary else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.processUnreadCounts(unreadCountDictionary: unreadCountDictionary, feeds: self.flattenedWebFeeds())
|
self.processUnreadCounts(unreadCountDictionary: unreadCountDictionary, feeds: self.flattenedWebFeeds())
|
||||||
|
@ -1296,8 +1291,6 @@ private extension Account {
|
||||||
self.postUnreadCountDidInitializeNotification()
|
self.postUnreadCountDidInitializeNotification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operationQueue.add(operation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func processUnreadCounts(unreadCountDictionary: UnreadCountDictionary, feeds: Set<WebFeed>) {
|
func processUnreadCounts(unreadCountDictionary: UnreadCountDictionary, feeds: Set<WebFeed>) {
|
||||||
|
|
|
@ -138,8 +138,10 @@ public final class ArticlesDatabase {
|
||||||
|
|
||||||
// MARK: - Unread Counts
|
// MARK: - Unread Counts
|
||||||
|
|
||||||
|
/// Fetch all non-zero unread counts.
|
||||||
public func fetchAllUnreadCounts(_ completion: @escaping UnreadCountDictionaryCompletionBlock) {
|
public func fetchAllUnreadCounts(_ completion: @escaping UnreadCountDictionaryCompletionBlock) {
|
||||||
let operation = FetchAllUnreadCountsOperation(databaseQueue: queue, cutoffDate: articlesTable.articleCutoffDate)
|
let operation = FetchAllUnreadCountsOperation(databaseQueue: queue, cutoffDate: articlesTable.articleCutoffDate)
|
||||||
|
operationQueue.cancelOperations(named: operation.name!)
|
||||||
operation.completionBlock = { operation in
|
operation.completionBlock = { operation in
|
||||||
let fetchOperation = operation as! FetchAllUnreadCountsOperation
|
let fetchOperation = operation as! FetchAllUnreadCountsOperation
|
||||||
completion(fetchOperation.result)
|
completion(fetchOperation.result)
|
||||||
|
@ -203,11 +205,6 @@ public final class ArticlesDatabase {
|
||||||
operationQueue.cancelAllOperations()
|
operationQueue.cancelAllOperations()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an operation that fetches all non-zero unread counts.
|
|
||||||
public func createFetchAllUnreadCountsOperation() -> FetchAllUnreadCountsOperation {
|
|
||||||
return FetchAllUnreadCountsOperation(databaseQueue: queue, cutoffDate: articlesTable.articleCutoffDate)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create an operation that fetches the unread count for a single given feedID.
|
/// Create an operation that fetches the unread count for a single given feedID.
|
||||||
public func createFetchFeedUnreadCountOperation(feedID: String) -> FetchFeedUnreadCountOperation {
|
public func createFetchFeedUnreadCountOperation(feedID: String) -> FetchFeedUnreadCountOperation {
|
||||||
return FetchFeedUnreadCountOperation(feedID: feedID, databaseQueue: queue, cutoffDate: articlesTable.articleCutoffDate)
|
return FetchFeedUnreadCountOperation(feedID: feedID, databaseQueue: queue, cutoffDate: articlesTable.articleCutoffDate)
|
||||||
|
|
|
@ -49,7 +49,7 @@ class AddAccountViewController: UITableViewController, AddAccountDismissDelegate
|
||||||
let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly)
|
let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly)
|
||||||
addAccount.delegate = self
|
addAccount.delegate = self
|
||||||
addAccount.presentationAnchor = self.view.window!
|
addAccount.presentationAnchor = self.view.window!
|
||||||
MainThreadOperationQueue.shared.addOperation(addAccount)
|
MainThreadOperationQueue.shared.add(addAccount)
|
||||||
case 3:
|
case 3:
|
||||||
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "FeedWranglerAccountNavigationViewController") as! UINavigationController
|
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "FeedWranglerAccountNavigationViewController") as! UINavigationController
|
||||||
navController.modalPresentationStyle = .currentContext
|
navController.modalPresentationStyle = .currentContext
|
||||||
|
|
Loading…
Reference in New Issue