mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-04 11:16:59 +00:00
Use Swift 6.2 with the app. Fix some concurrency issues.
This commit is contained in:
1 parent
cc71198195
commit
653789b913
7 files changed
+31
-27
No files matched your search
@@ -17,7 +17,7 @@ import CrashReporter
|
||||
// At some point this code should probably move into RSCore, so Rainier and any other
|
||||
// future apps can use it.
|
||||
|
||||
struct CrashReporter {
|
||||
@MainActor struct CrashReporter {
|
||||
|
||||
struct DefaultsKey {
|
||||
static let sendCrashLogsAutomaticallyKey = "SendCrashLogsAutomatically"
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import UserNotifications
|
||||
import Synchronization
|
||||
import Articles
|
||||
import Account
|
||||
import UserNotifications
|
||||
|
||||
final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
|
||||
@@ -28,7 +29,7 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
}
|
||||
}
|
||||
|
||||
private var userNotificationSettings: UNNotificationSettings?
|
||||
private var authorizationStatus: UNAuthorizationStatus?
|
||||
|
||||
// MARK: Inspector
|
||||
|
||||
@@ -63,7 +64,7 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
|
||||
// MARK: Actions
|
||||
@IBAction func isNotifyAboutNewArticlesChanged(_ sender: Any) {
|
||||
guard userNotificationSettings != nil else {
|
||||
guard authorizationStatus != nil else {
|
||||
DispatchQueue.main.async {
|
||||
self.isNotifyAboutNewArticlesCheckBox.setNextState()
|
||||
}
|
||||
@@ -71,7 +72,9 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
}
|
||||
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
self.updateNotificationSettings()
|
||||
Task { @MainActor in
|
||||
self.updateNotificationSettings()
|
||||
}
|
||||
|
||||
if settings.authorizationStatus == .denied {
|
||||
DispatchQueue.main.async {
|
||||
@@ -84,15 +87,17 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
}
|
||||
} else {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
||||
self.updateNotificationSettings()
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
||||
NSApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
self.isNotifyAboutNewArticlesCheckBox.setNextState()
|
||||
Task { @MainActor in
|
||||
self.updateNotificationSettings()
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
||||
NSApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
self.isNotifyAboutNewArticlesCheckBox.setNextState()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,9 +185,10 @@ private extension FeedInspectorViewController {
|
||||
|
||||
func updateNotificationSettings() {
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
self.userNotificationSettings = settings
|
||||
if settings.authorizationStatus == .authorized {
|
||||
DispatchQueue.main.async {
|
||||
let authorizationStatus = settings.authorizationStatus
|
||||
Task { @MainActor in
|
||||
self.authorizationStatus = authorizationStatus
|
||||
if self.authorizationStatus == .authorized {
|
||||
NSApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import AppKit
|
||||
|
||||
protocol Inspector: AnyObject {
|
||||
@MainActor protocol Inspector: AnyObject {
|
||||
|
||||
var objects: [Any]? { get set }
|
||||
var isFallbackInspector: Bool { get } // Can handle nothing-to-inspect or unexpected type of objects.
|
||||
|
||||
@@ -12,7 +12,7 @@ import RSCore
|
||||
import RSWeb
|
||||
import Articles
|
||||
|
||||
protocol DetailWebViewControllerDelegate: AnyObject {
|
||||
@MainActor protocol DetailWebViewControllerDelegate: AnyObject {
|
||||
func mouseDidEnter(_: DetailWebViewController, link: String)
|
||||
func mouseDidExit(_: DetailWebViewController)
|
||||
}
|
||||
|
||||
+2
-5
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// MainWIndowKeyboardHandler.swift
|
||||
// MainWindowKeyboardHandler.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Brent Simmons on 12/19/17.
|
||||
@@ -9,13 +9,11 @@
|
||||
import AppKit
|
||||
import RSCore
|
||||
|
||||
final class MainWindowKeyboardHandler: KeyboardDelegate {
|
||||
|
||||
@MainActor final class MainWindowKeyboardHandler: KeyboardDelegate {
|
||||
static let shared = MainWindowKeyboardHandler()
|
||||
let globalShortcuts: Set<KeyboardShortcut>
|
||||
|
||||
init() {
|
||||
|
||||
let f = Bundle.main.path(forResource: "GlobalKeyboardShortcuts", ofType: "plist")!
|
||||
let rawShortcuts = NSArray(contentsOfFile: f)! as! [[String: Any]]
|
||||
|
||||
@@ -23,7 +21,6 @@ final class MainWindowKeyboardHandler: KeyboardDelegate {
|
||||
}
|
||||
|
||||
func keydown(_ event: NSEvent, in view: NSView) -> Bool {
|
||||
|
||||
let key = KeyboardKey(with: event)
|
||||
guard let matchingShortcut = KeyboardShortcut.findMatchingShortcut(in: globalShortcuts, key: key) else {
|
||||
return false
|
||||
@@ -9,8 +9,8 @@
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
|
||||
@objc public protocol KeyboardDelegate: AnyObject {
|
||||
@MainActor @objc public protocol KeyboardDelegate: AnyObject {
|
||||
// Return true if handled.
|
||||
@MainActor func keydown(_: NSEvent, in view: NSView) -> Bool
|
||||
func keydown(_: NSEvent, in view: NSView) -> Bool
|
||||
}
|
||||
#endif
|
||||
@@ -51,8 +51,9 @@ IPHONEOS_DEPLOYMENT_TARGET = 26.0
|
||||
//SDKROOT = macosx
|
||||
SWIFT_EMIT_LOC_STRINGS = YES
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off
|
||||
SWIFT_VERSION = 5.10
|
||||
SWIFT_VERSION = 6.2
|
||||
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES
|
||||
OTHER_SWIFT_FLAGS = $(inherited) -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-upcoming-feature InferIsolatedConformances
|
||||
|
||||
// https://forums.swift.org/t/swift-packages-in-multiple-targets-results-in-this-will-result-in-duplication-of-library-code-errors/34892/33
|
||||
DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC = YES
|
||||
Reference in new issue
Block a user