Skip to content

Commit

Permalink
Use enum for user settings keys
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingajda committed Apr 7, 2020
1 parent d769f7f commit c1570ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Covid-19 Status/src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
alertsEnabled = enabled
notificator.isEnabled = enabled
alertsMenuItem?.state = enabled ? .on : .off
settings.set(enabled, forKey: "alerts")
settings.set(enabled, forKey: SettingsKey.alertsEnabled.rawValue)
}

@IBAction func alertsSwitchHandler(_ sender: NSMenuItem) {
Expand Down Expand Up @@ -116,12 +116,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
statusBarItem?.menu = menu
display.setComponents(statusItem: button, deltaItem: deltaMenuItem)

setAlertsEnabled(enabled: settings.bool(forKey: "alerts"))
setAlertsEnabled(enabled: settings.bool(forKey: SettingsKey.alertsEnabled.rawValue))

regionsMenu.onRegionChange(callback: onRegionChange)
provider = DataProvider(onSuccess: onUpdateSuccess, onError: onUpdateFailure)

let prefferedRegion = settings.string(forKey: "country")
let prefferedRegion = settings.string(forKey: SettingsKey.selectedRegion.rawValue)
regionsMenu.setCurrent(region: prefferedRegion ?? SpecialRegions.world.rawValue)

provider?.doUpdate()
Expand Down
2 changes: 1 addition & 1 deletion Covid-19 Status/src/components/RegionsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RegionsMenu: NSMenu {
findItem(name: region)?.state = .on

currentRegion = region
settings.set(region, forKey: "country")
settings.set(region, forKey: SettingsKey.selectedRegion.rawValue)
regionChangeCallback?(region)
}

Expand Down

0 comments on commit c1570ad

Please sign in to comment.