mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 00:31:14 +00:00
Fix various concurrency issues.
This commit is contained in:
1 parent
415a6f4661
commit
563d1febbc
6 files changed
+25
-29
No files matched your search
@@ -197,6 +197,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat
|
||||
self.toggleInspectorWindow(self)
|
||||
}
|
||||
|
||||
ArticleThemesManager.shared.start()
|
||||
NetworkMonitor.shared.start()
|
||||
ExtensionContainersFile.shared.start()
|
||||
ExtensionFeedAddRequestFile.shared.start()
|
||||
|
||||
@@ -14,7 +14,7 @@ import AppKit
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
enum AddCloudKitAccountError: LocalizedError, RecoverableError {
|
||||
enum AddCloudKitAccountError: LocalizedError, RecoverableError, Sendable {
|
||||
|
||||
case iCloudDriveMissing
|
||||
|
||||
@@ -43,7 +43,10 @@ enum AddCloudKitAccountError: LocalizedError, RecoverableError {
|
||||
return false
|
||||
}
|
||||
|
||||
AddCloudKitAccountUtilities.openiCloudSettings()
|
||||
Task { @MainActor in
|
||||
AddCloudKitAccountUtilities.openiCloudSettings()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -54,7 +57,7 @@ struct AddCloudKitAccountUtilities {
|
||||
FileManager.default.ubiquityIdentityToken != nil
|
||||
}
|
||||
|
||||
static func openiCloudSettings() {
|
||||
@MainActor static func openiCloudSettings() {
|
||||
#if os(macOS)
|
||||
if let url = URL(string: "x-apple.systempreferences:com.apple.preferences.AppleIDPrefPane") {
|
||||
NSWorkspace.shared.open(url)
|
||||
|
||||
@@ -16,9 +16,9 @@ import Account
|
||||
import Articles
|
||||
import Secrets
|
||||
|
||||
var appDelegate: AppDelegate!
|
||||
@MainActor var appDelegate: AppDelegate!
|
||||
|
||||
@UIApplicationMain
|
||||
@main
|
||||
final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, UnreadCountProvider {
|
||||
|
||||
private let backgroundTaskDispatchQueue = DispatchQueue.init(label: "BGTaskScheduler")
|
||||
@@ -52,15 +52,8 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
|
||||
super.init()
|
||||
appDelegate = self
|
||||
|
||||
let documentFolder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
let documentAccountsFolder = documentFolder.appendingPathComponent("Accounts").absoluteString
|
||||
|
||||
AccountManager.shared.start()
|
||||
|
||||
let documentThemesFolder = documentFolder.appendingPathComponent("Themes").absoluteString
|
||||
let documentThemesFolderPath = String(documentThemesFolder.suffix(from: documentAccountsFolder.index(documentThemesFolder.startIndex, offsetBy: 7)))
|
||||
ArticleThemesManager.shared = ArticleThemesManager(folderPath: documentThemesFolderPath)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(accountRefreshDidFinish(_:)), name: .AccountRefreshDidFinish, object: nil)
|
||||
}
|
||||
@@ -100,6 +93,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
|
||||
UNUserNotificationCenter.current().delegate = self
|
||||
UserNotificationManager.shared.start()
|
||||
|
||||
ArticleThemesManager.shared.start()
|
||||
NetworkMonitor.shared.start()
|
||||
ExtensionContainersFile.shared.start()
|
||||
ExtensionFeedAddRequestFile.shared.start()
|
||||
|
||||
@@ -33,7 +33,7 @@ final class FeedInspectorViewController: UITableViewController {
|
||||
return feed.homePageURL == nil
|
||||
}
|
||||
|
||||
private var userNotificationSettings: UNNotificationSettings?
|
||||
private var authorizationStatus: UNAuthorizationStatus?
|
||||
|
||||
override func viewDidLoad() {
|
||||
tableView.register(InspectorIconHeaderView.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")
|
||||
@@ -72,25 +72,23 @@ final class FeedInspectorViewController: UITableViewController {
|
||||
}
|
||||
|
||||
@IBAction func notifyAboutNewArticlesChanged(_ sender: Any) {
|
||||
guard let settings = userNotificationSettings else {
|
||||
guard let authorizationStatus else {
|
||||
notifyAboutNewArticlesSwitch.isOn = !notifyAboutNewArticlesSwitch.isOn
|
||||
return
|
||||
}
|
||||
if settings.authorizationStatus == .denied {
|
||||
if authorizationStatus == .denied {
|
||||
notifyAboutNewArticlesSwitch.isOn = !notifyAboutNewArticlesSwitch.isOn
|
||||
present(notificationUpdateErrorAlert(), animated: true, completion: nil)
|
||||
} else if settings.authorizationStatus == .authorized {
|
||||
} else if authorizationStatus == .authorized {
|
||||
feed.isNotifyAboutNewArticles = notifyAboutNewArticlesSwitch.isOn
|
||||
} else {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .sound, .alert]) { (granted, error) in
|
||||
self.updateNotificationSettings()
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
Task { @MainActor in
|
||||
self.updateNotificationSettings()
|
||||
if granted {
|
||||
self.feed.isNotifyAboutNewArticles = self.notifyAboutNewArticlesSwitch.isOn
|
||||
UIApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
} else {
|
||||
self.notifyAboutNewArticlesSwitch.isOn = !self.notifyAboutNewArticlesSwitch.isOn
|
||||
}
|
||||
}
|
||||
@@ -199,12 +197,12 @@ extension FeedInspectorViewController: UITextFieldDelegate {
|
||||
|
||||
extension FeedInspectorViewController {
|
||||
|
||||
@objc
|
||||
func updateNotificationSettings() {
|
||||
@objc func updateNotificationSettings() {
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
let updatedAuthorizationStatus = settings.authorizationStatus
|
||||
DispatchQueue.main.async {
|
||||
self.userNotificationSettings = settings
|
||||
if settings.authorizationStatus == .authorized {
|
||||
self.authorizationStatus = updatedAuthorizationStatus
|
||||
if self.authorizationStatus == .authorized {
|
||||
UIApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
enum KeyboardType: String {
|
||||
enum KeyboardType: String, Sendable {
|
||||
case global = "GlobalKeyboardShortcuts"
|
||||
case sidebar = "SidebarKeyboardShortcuts"
|
||||
case timeline = "TimelineKeyboardShortcuts"
|
||||
case detail = "DetailKeyboardShortcuts"
|
||||
}
|
||||
|
||||
final class KeyboardManager {
|
||||
@MainActor final class KeyboardManager {
|
||||
|
||||
private(set) var _keyCommands: [UIKeyCommand]
|
||||
var keyCommands: [UIKeyCommand] {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
protocol MainFeedCollectionViewFolderCellDelegate: AnyObject {
|
||||
@MainActor protocol MainFeedCollectionViewFolderCellDelegate: AnyObject {
|
||||
func mainFeedCollectionFolderViewCellDisclosureDidToggle(_ sender: MainFeedCollectionViewFolderCell, expanding: Bool)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user