Simplify prefs window

This commit is contained in:
DC
2016-05-24 01:43:59 -07:00
parent 12f9709601
commit a59faacbd7
2 changed files with 57 additions and 104 deletions

View File

@@ -542,6 +542,9 @@ function resumeTorrents () {
.forEach((x) => startTorrentingSummary(x))
}
// Updates a single property in the UNSAVED prefs
// For example: updatePreferences("foo.bar", "baz")
// Call savePreferences to save to config.json
function updatePreferences (property, value) {
var path = property.split('.')
var key = state.unsaved.prefs
@@ -554,6 +557,7 @@ function updatePreferences (property, value) {
key[path[i]] = value
}
// All unsaved prefs take effect atomically, and are saved to config.json
function savePreferences () {
state.saved.prefs = Object.assign(state.saved.prefs || {}, state.unsaved.prefs)
saveState()