1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Remove port pref if it's 0 or nil

This commit is contained in:
Daniel Barber 2019-02-15 17:21:15 -05:00
parent 32f8c68af2
commit 97ee384007
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -23,7 +23,11 @@ struct Preferences {
return UserDefaults.standard.value(forKey: "mpdPort") as? Int
}
set {
UserDefaults.standard.set(newValue, forKey: "mpdPort")
if (newValue.map { $0 > 0 } ?? false) {
UserDefaults.standard.set(newValue, forKey: "mpdPort")
} else {
UserDefaults.standard.removeObject(forKey: "mpdPort")
}
}
}