mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix test-time crashes by making sure some main thread code runs on main thread.
This commit is contained in:
@@ -363,15 +363,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
updateSortMenuItems()
|
||||
updateGroupByFeedMenuItem()
|
||||
|
||||
if lastRefreshInterval != AppDefaults.shared.refreshInterval {
|
||||
refreshTimer?.update()
|
||||
lastRefreshInterval = AppDefaults.shared.refreshInterval
|
||||
Task { @MainActor in
|
||||
updateSortMenuItems()
|
||||
updateGroupByFeedMenuItem()
|
||||
|
||||
if lastRefreshInterval != AppDefaults.shared.refreshInterval {
|
||||
refreshTimer?.update()
|
||||
lastRefreshInterval = AppDefaults.shared.refreshInterval
|
||||
}
|
||||
|
||||
updateDockBadge()
|
||||
}
|
||||
|
||||
updateDockBadge()
|
||||
}
|
||||
|
||||
@objc func didWakeNotification(_ note: Notification) {
|
||||
@@ -504,8 +506,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
// MARK: - Dock Badge
|
||||
@objc func updateDockBadge() {
|
||||
let label = unreadCount > 0 ? "\(unreadCount)" : ""
|
||||
NSApplication.shared.dockTile.badgeLabel = label
|
||||
Task { @MainActor in
|
||||
let label = unreadCount > 0 ? "\(unreadCount)" : ""
|
||||
NSApplication.shared.dockTile.badgeLabel = label
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
@@ -768,13 +772,13 @@ internal extension AppDelegate {
|
||||
inspectorWindowController?.saveState()
|
||||
}
|
||||
|
||||
func updateSortMenuItems() {
|
||||
@MainActor func updateSortMenuItems() {
|
||||
let sortByNewestOnTop = AppDefaults.shared.timelineSortDirection == .orderedDescending
|
||||
sortByNewestArticleOnTopMenuItem.state = sortByNewestOnTop ? .on : .off
|
||||
sortByOldestArticleOnTopMenuItem.state = sortByNewestOnTop ? .off : .on
|
||||
}
|
||||
|
||||
func updateGroupByFeedMenuItem() {
|
||||
@MainActor func updateGroupByFeedMenuItem() {
|
||||
let groupByFeedEnabled = AppDefaults.shared.timelineGroupByFeed
|
||||
groupArticlesByFeedMenuItem.state = groupByFeedEnabled ? .on : .off
|
||||
}
|
||||
|
||||
@@ -159,9 +159,11 @@ private extension DetailViewController {
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ : Notification) {
|
||||
if AppDefaults.shared.isArticleContentJavascriptEnabled != isArticleContentJavascriptEnabled {
|
||||
isArticleContentJavascriptEnabled = AppDefaults.shared.isArticleContentJavascriptEnabled
|
||||
createNewWebViewsAndRestoreState()
|
||||
Task { @MainActor in
|
||||
if AppDefaults.shared.isArticleContentJavascriptEnabled != isArticleContentJavascriptEnabled {
|
||||
isArticleContentJavascriptEnabled = AppDefaults.shared.isArticleContentJavascriptEnabled
|
||||
createNewWebViewsAndRestoreState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -665,9 +665,11 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
self.fontSize = AppDefaults.shared.timelineFontSize
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
Task { @MainActor in
|
||||
self.fontSize = AppDefaults.shared.timelineFontSize
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Reloading Data
|
||||
|
||||
@@ -50,7 +50,7 @@ final class AdvancedPreferencesViewController: NSViewController {
|
||||
|
||||
private extension AdvancedPreferencesViewController {
|
||||
|
||||
func updateUI() {
|
||||
@MainActor func updateUI() {
|
||||
if wantsTestBuilds {
|
||||
testBuildsButton.state = .on
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ class MainTimelineViewController: UITableViewController, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
DispatchQueue.main.async {
|
||||
Task { @MainActor in
|
||||
if self.numberOfTextLines != AppDefaults.shared.timelineNumberOfLines || self.iconSize != AppDefaults.shared.timelineIconSize {
|
||||
self.numberOfTextLines = AppDefaults.shared.timelineNumberOfLines
|
||||
self.iconSize = AppDefaults.shared.timelineIconSize
|
||||
@@ -518,7 +518,7 @@ class MainTimelineViewController: UITableViewController, UndoableCommandRunner {
|
||||
self.updateToolbar()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@objc func contentSizeCategoryDidChange(_ note: Notification) {
|
||||
reloadAllVisibleCells()
|
||||
}
|
||||
|
||||
@@ -493,8 +493,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
Task { @MainActor in
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
}
|
||||
}
|
||||
|
||||
@objc func accountDidDownloadArticles(_ note: Notification) {
|
||||
|
||||
@@ -234,22 +234,19 @@ private extension SceneDelegate {
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange() {
|
||||
updateUserInterfaceStyle()
|
||||
}
|
||||
|
||||
func updateUserInterfaceStyle() {
|
||||
DispatchQueue.main.async {
|
||||
switch AppDefaults.userInterfaceColorPalette {
|
||||
case .automatic:
|
||||
self.window?.overrideUserInterfaceStyle = .unspecified
|
||||
case .light:
|
||||
self.window?.overrideUserInterfaceStyle = .light
|
||||
case .dark:
|
||||
self.window?.overrideUserInterfaceStyle = .dark
|
||||
}
|
||||
Task {
|
||||
updateUserInterfaceStyle()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor func updateUserInterfaceStyle() {
|
||||
switch AppDefaults.userInterfaceColorPalette {
|
||||
case .automatic:
|
||||
self.window?.overrideUserInterfaceStyle = .unspecified
|
||||
case .light:
|
||||
self.window?.overrideUserInterfaceStyle = .light
|
||||
case .dark:
|
||||
self.window?.overrideUserInterfaceStyle = .dark
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user