mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Invert the semantics of the defaults key for whether to open Subscribe to Feed feeds in NNW or the user's configured default browser. This ensures the fallback behavior when no preference has been set will default as wanted to opening in NetNewsWire.
This commit is contained in:
parent
8191f2476a
commit
29af6dea1e
@ -30,7 +30,7 @@ final class AppDefaults {
|
|||||||
static let timelineGroupByFeed = "timelineGroupByFeed"
|
static let timelineGroupByFeed = "timelineGroupByFeed"
|
||||||
static let detailFontSize = "detailFontSize"
|
static let detailFontSize = "detailFontSize"
|
||||||
static let openInBrowserInBackground = "openInBrowserInBackground"
|
static let openInBrowserInBackground = "openInBrowserInBackground"
|
||||||
static let subscribeToFeedsInNetNewsWire = "subscribeToFeedsInNetNewsWire"
|
static let subscribeToFeedsInDefaultBrowser = "subscribeToFeedsInDefaultBrowser"
|
||||||
static let articleTextSize = "articleTextSize"
|
static let articleTextSize = "articleTextSize"
|
||||||
static let refreshInterval = "refreshInterval"
|
static let refreshInterval = "refreshInterval"
|
||||||
static let addWebFeedAccountID = "addWebFeedAccountID"
|
static let addWebFeedAccountID = "addWebFeedAccountID"
|
||||||
@ -107,12 +107,12 @@ final class AppDefaults {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var subscribeToFeedsInNetNewsWire: Bool {
|
var subscribeToFeedsInDefaultBrowser: Bool {
|
||||||
get {
|
get {
|
||||||
return AppDefaults.bool(for: Key.subscribeToFeedsInNetNewsWire)
|
return AppDefaults.bool(for: Key.subscribeToFeedsInDefaultBrowser)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
AppDefaults.setBool(for: Key.subscribeToFeedsInNetNewsWire, newValue)
|
AppDefaults.setBool(for: Key.subscribeToFeedsInDefaultBrowser, newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ final class AppDefaults {
|
|||||||
Key.detailFontSize: FontSize.medium.rawValue,
|
Key.detailFontSize: FontSize.medium.rawValue,
|
||||||
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
||||||
Key.timelineGroupByFeed: false,
|
Key.timelineGroupByFeed: false,
|
||||||
Key.subscribeToFeedsInNetNewsWire: true,
|
Key.subscribeToFeedsInDefaultBrowser: false,
|
||||||
"NSScrollViewShouldScrollUnderTitlebar": false,
|
"NSScrollViewShouldScrollUnderTitlebar": false,
|
||||||
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
|
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
|
||||||
Key.showDebugMenu: showDebugMenu]
|
Key.showDebugMenu: showDebugMenu]
|
||||||
|
@ -190,7 +190,11 @@
|
|||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
<connections>
|
<connections>
|
||||||
<binding destination="mAF-gO-1PI" name="value" keyPath="values.subscribeToFeedsInNetNewsWire" id="Q15-dB-PCt"/>
|
<binding destination="mAF-gO-1PI" name="value" keyPath="values.subscribeToFeedsInDefaultBrowser" id="rgT-1E-AoD">
|
||||||
|
<dictionary key="options">
|
||||||
|
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||||
|
</dictionary>
|
||||||
|
</binding>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Yrc-6Q-kx8">
|
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Yrc-6Q-kx8">
|
||||||
@ -200,11 +204,7 @@
|
|||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
<connections>
|
<connections>
|
||||||
<binding destination="mAF-gO-1PI" name="value" keyPath="values.subscribeToFeedsInNetNewsWire" id="Ikq-MR-S1U">
|
<binding destination="mAF-gO-1PI" name="value" keyPath="values.subscribeToFeedsInDefaultBrowser" id="Dnc-co-ppt"/>
|
||||||
<dictionary key="options">
|
|
||||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
|
||||||
</dictionary>
|
|
||||||
</binding>
|
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
|
@ -43,6 +43,8 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) {
|
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) {
|
||||||
if (messageName == "subscribeToFeed") {
|
if (messageName == "subscribeToFeed") {
|
||||||
if var feedURLString = userInfo?["url"] as? String {
|
if var feedURLString = userInfo?["url"] as? String {
|
||||||
|
var openInDefaultBrowser = false
|
||||||
|
|
||||||
// Ask for the user default from NetNewsWire's defaults to determine whether to open the feed URL
|
// Ask for the user default from NetNewsWire's defaults to determine whether to open the feed URL
|
||||||
// using whatever the system configured default is, or to always hard-code it to NetNewsWire itself.
|
// using whatever the system configured default is, or to always hard-code it to NetNewsWire itself.
|
||||||
if let pluginBundleID = Bundle.main.bundleIdentifier {
|
if let pluginBundleID = Bundle.main.bundleIdentifier {
|
||||||
@ -51,12 +53,14 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
let hostAppBundleID = pluginBundleID.replacingOccurrences(of: ".Subscribe-to-Feed", with: "")
|
let hostAppBundleID = pluginBundleID.replacingOccurrences(of: ".Subscribe-to-Feed", with: "")
|
||||||
|
|
||||||
if let sharedDefaults = UserDefaults(suiteName: hostAppBundleID) {
|
if let sharedDefaults = UserDefaults(suiteName: hostAppBundleID) {
|
||||||
let openInNNW = sharedDefaults.bool(forKey: "subscribeToFeedsInNetNewsWire")
|
openInDefaultBrowser = sharedDefaults.bool(forKey: "subscribeToFeedsInDefaultBrowser")
|
||||||
if openInNNW {
|
|
||||||
feedURLString = feedURLString.replacingOccurrences(of: "feed:", with: "x-netnewswire-feed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if openInDefaultBrowser == false {
|
||||||
|
feedURLString = feedURLString.replacingOccurrences(of: "feed:", with: "x-netnewswire-feed")
|
||||||
|
}
|
||||||
|
|
||||||
if let feedURL = URL(string: feedURLString) {
|
if let feedURL = URL(string: feedURLString) {
|
||||||
NSWorkspace.shared.open(feedURL)
|
NSWorkspace.shared.open(feedURL)
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ final class AppDefaults: ObservableObject {
|
|||||||
static let articleTextSize = "articleTextSize"
|
static let articleTextSize = "articleTextSize"
|
||||||
static let openInBrowserInBackground = "openInBrowserInBackground"
|
static let openInBrowserInBackground = "openInBrowserInBackground"
|
||||||
static let defaultBrowserID = "defaultBrowserID"
|
static let defaultBrowserID = "defaultBrowserID"
|
||||||
static let subscribeToFeedsInNetNewsWire = "subscribeToFeedsInNetNewsWire"
|
static let subscribeToFeedsInDefaultBrowser = "subscribeToFeedsInDefaultBrowser"
|
||||||
static let checkForUpdatesAutomatically = "checkForUpdatesAutomatically"
|
static let checkForUpdatesAutomatically = "checkForUpdatesAutomatically"
|
||||||
static let downloadTestBuilds = "downloadTestBuild"
|
static let downloadTestBuilds = "downloadTestBuild"
|
||||||
static let sendCrashLogs = "sendCrashLogs"
|
static let sendCrashLogs = "sendCrashLogs"
|
||||||
@ -267,7 +267,7 @@ final class AppDefaults: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AppStorage(wrappedValue: false, Key.subscribeToFeedsInNetNewsWire, store: store) var subscribeToFeedsInNetNewsWire: Bool {
|
@AppStorage(wrappedValue: false, Key.subscribeToFeedsInDefaultBrowser, store: store) var subscribeToFeedsInDefaultBrowser: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
objectWillChange.send()
|
objectWillChange.send()
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ struct GeneralPreferencesView: View {
|
|||||||
Toggle("Hide Unread Count in Dock", isOn: $defaults.hideDockUnreadCount)
|
Toggle("Hide Unread Count in Dock", isOn: $defaults.hideDockUnreadCount)
|
||||||
|
|
||||||
Picker("Safari Extension:",
|
Picker("Safari Extension:",
|
||||||
selection: $defaults.subscribeToFeedsInNetNewsWire,
|
selection: $defaults.subscribeToFeedsInDefaultBrowser,
|
||||||
content: {
|
content: {
|
||||||
Text("Open feeds in NetNewsWire").tag(true)
|
Text("Open feeds in NetNewsWire").tag(false)
|
||||||
Text("Open feeds in default news reader").tag(false)
|
Text("Open feeds in default news reader").tag(true)
|
||||||
}).pickerStyle(RadioGroupPickerStyle())
|
}).pickerStyle(RadioGroupPickerStyle())
|
||||||
}
|
}
|
||||||
.frame(width: 400, alignment: .center)
|
.frame(width: 400, alignment: .center)
|
||||||
|
Loading…
Reference in New Issue
Block a user