mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-09 16:32:46 +01:00
Make SmartFeed MainActor.
This commit is contained in:
parent
74a42c6f3e
commit
3e53dfbfc6
@ -14,7 +14,7 @@ import Database
|
|||||||
import Core
|
import Core
|
||||||
import Images
|
import Images
|
||||||
|
|
||||||
final class SmartFeed: PseudoFeed {
|
@MainActor final class SmartFeed: PseudoFeed {
|
||||||
|
|
||||||
var account: Account? = nil
|
var account: Account? = nil
|
||||||
|
|
||||||
@ -60,19 +60,19 @@ final class SmartFeed: PseudoFeed {
|
|||||||
private let delegate: SmartFeedDelegate
|
private let delegate: SmartFeedDelegate
|
||||||
private var unreadCounts = [String: Int]()
|
private var unreadCounts = [String: Int]()
|
||||||
|
|
||||||
@MainActor init(delegate: SmartFeedDelegate) {
|
init(delegate: SmartFeedDelegate) {
|
||||||
self.delegate = delegate
|
self.delegate = delegate
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||||
queueFetchUnreadCounts() // Fetch unread count at startup
|
queueFetchUnreadCounts() // Fetch unread count at startup
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor @objc func unreadCountDidChange(_ note: Notification) {
|
@objc func unreadCountDidChange(_ note: Notification) {
|
||||||
if note.object is AppDelegate {
|
if note.object is AppDelegate {
|
||||||
queueFetchUnreadCounts()
|
queueFetchUnreadCounts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor func fetchUnreadCounts() async throws {
|
func fetchUnreadCounts() async throws {
|
||||||
|
|
||||||
let activeAccounts = AccountManager.shared.activeAccounts
|
let activeAccounts = AccountManager.shared.activeAccounts
|
||||||
|
|
||||||
@ -110,12 +110,12 @@ extension SmartFeed: ArticleFetcher {
|
|||||||
|
|
||||||
private extension SmartFeed {
|
private extension SmartFeed {
|
||||||
|
|
||||||
@MainActor func queueFetchUnreadCounts() {
|
func queueFetchUnreadCounts() {
|
||||||
|
|
||||||
postponingBlock.runInFuture()
|
postponingBlock.runInFuture()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor func fetchUnreadCount(for account: Account) async {
|
func fetchUnreadCount(for account: Account) async {
|
||||||
|
|
||||||
let unreadCount = await delegate.unreadCount(account: account)
|
let unreadCount = await delegate.unreadCount(account: account)
|
||||||
unreadCounts[account.accountID] = unreadCount
|
unreadCounts[account.accountID] = unreadCount
|
||||||
@ -123,7 +123,7 @@ private extension SmartFeed {
|
|||||||
updateUnreadCount()
|
updateUnreadCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor func updateUnreadCount() {
|
func updateUnreadCount() {
|
||||||
|
|
||||||
var unread = 0
|
var unread = 0
|
||||||
for account in AccountManager.shared.activeAccounts {
|
for account in AccountManager.shared.activeAccounts {
|
||||||
|
Loading…
Reference in New Issue
Block a user