Fixes bug #1137
This commit is contained in:
@ -130,6 +130,7 @@ class PreferencesWindowController: NSWindowController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func cancel(_ sender: NSButton) {
|
@IBAction func cancel(_ sender: NSButton) {
|
||||||
|
profileMgr.reload()
|
||||||
window?.performClose(self)
|
window?.performClose(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,10 @@ class ServerProfileManager: NSObject {
|
|||||||
|
|
||||||
static let instance:ServerProfileManager = ServerProfileManager()
|
static let instance:ServerProfileManager = ServerProfileManager()
|
||||||
|
|
||||||
var profiles:[ServerProfile]
|
var profiles:[ServerProfile] = [ServerProfile]()
|
||||||
var activeProfileId: String?
|
var activeProfileId: String?
|
||||||
|
|
||||||
fileprivate override init() {
|
fileprivate override init() {
|
||||||
profiles = [ServerProfile]()
|
|
||||||
|
|
||||||
let defaults = UserDefaults.standard
|
let defaults = UserDefaults.standard
|
||||||
if let _profiles = defaults.array(forKey: "ServerProfiles") {
|
if let _profiles = defaults.array(forKey: "ServerProfiles") {
|
||||||
for _profile in _profiles {
|
for _profile in _profiles {
|
||||||
@ -50,6 +48,19 @@ class ServerProfileManager: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reload() {
|
||||||
|
profiles.removeAll()
|
||||||
|
|
||||||
|
let defaults = UserDefaults.standard
|
||||||
|
if let _profiles = defaults.array(forKey: "ServerProfiles") {
|
||||||
|
for _profile in _profiles {
|
||||||
|
let profile = ServerProfile.fromDictionary(_profile as! [String: Any])
|
||||||
|
profiles.append(profile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activeProfileId = defaults.string(forKey: "ActiveServerProfileId")
|
||||||
|
}
|
||||||
|
|
||||||
func getActiveProfile() -> ServerProfile? {
|
func getActiveProfile() -> ServerProfile? {
|
||||||
if let id = activeProfileId {
|
if let id = activeProfileId {
|
||||||
for p in profiles {
|
for p in profiles {
|
||||||
|
Reference in New Issue
Block a user