Merge pull request #551 from danielpunkass/fix-state-restoration

Work around case #550 by imposing the NSQuitAlwaysKeepsWindows defaul…
This commit is contained in:
Brent Simmons 2019-02-15 14:45:46 -08:00 committed by GitHub
commit 835267629b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -133,6 +133,18 @@ struct AppDefaults {
let defaults: [String : Any] = [Key.sidebarFontSize: FontSize.medium.rawValue, Key.timelineFontSize: FontSize.medium.rawValue, Key.detailFontSize: FontSize.medium.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, "NSScrollViewShouldScrollUnderTitlebar": false, Key.refreshInterval: RefreshInterval.everyHour.rawValue]
UserDefaults.standard.register(defaults: defaults)
// It seems that registering a default for NSQuitAlwaysKeepsWindows to true
// is not good enough to get the system to respect it, so we have to literally
// set it as the default to get it to take effect. This overrides a system-wide
// setting in the System Preferences, which is ostensibly meant to "close windows"
// in an app, but has the side-effect of also not preserving or restoring any state
// for the window. Since we've switched to using the standard state preservation and
// restoration mechanisms, and because it seems highly unlikely any user would object
// to NetNewsWire preserving this state, we'll force the preference on. If this becomes
// an issue, this could be changed to proactively look for whether the default has been
// set _by the user_ to false, and respect that default if it is so-set.
UserDefaults.standard.set(true, forKey: "NSQuitAlwaysKeepsWindows")
}
static func actualFontSize(for fontSize: FontSize) -> CGFloat {