mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add completion callbacks so that we can ensure that unreads have been marked before determining the next unread. Fixes #2993
This commit is contained in:
@@ -13,15 +13,24 @@ import Account
|
||||
|
||||
// These handle multiple accounts.
|
||||
|
||||
func markArticles(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) {
|
||||
func markArticles(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool, completion: (() -> Void)? = nil) {
|
||||
|
||||
let d: [String: Set<Article>] = accountAndArticlesDictionary(articles)
|
||||
|
||||
let group = DispatchGroup()
|
||||
|
||||
for (accountID, accountArticles) in d {
|
||||
guard let account = AccountManager.shared.existingAccount(with: accountID) else {
|
||||
continue
|
||||
}
|
||||
account.markArticles(accountArticles, statusKey: statusKey, flag: flag)
|
||||
group.enter()
|
||||
account.markArticles(accountArticles, statusKey: statusKey, flag: flag) { _ in
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
|
||||
group.notify(queue: .main) {
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user