aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/main.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-04-25 16:48:45 +0100
committerStephen Blott2015-04-25 16:48:45 +0100
commite620be90e8a3ce705d6d57298cb93af78f6eecb1 (patch)
tree7798b5b8d757312acda3baf30415d67ad3dd8772 /background_scripts/main.coffee
parentd0ca0745dc6b1818d2197ff51b0ed4d90fb6bc64 (diff)
parent838e1a8b97c7d1e868a9d4ed6b362a35c9455252 (diff)
downloadvimium-e620be90e8a3ce705d6d57298cb93af78f6eecb1.tar.bz2
Merge pull request #1581 from smblott-github/fetch-settings
Simplify front-end settings logic.
Diffstat (limited to 'background_scripts/main.coffee')
-rw-r--r--background_scripts/main.coffee16
1 files changed, 10 insertions, 6 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 5f0effcb..e782a217 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -204,12 +204,16 @@ selectSpecificTab = (request) ->
#
# Used by the content scripts to get settings from the local storage.
#
-handleSettings = (args, port) ->
- if (args.operation == "get")
- value = Settings.get(args.key)
- port.postMessage({ key: args.key, value: value })
- else # operation == "set"
- Settings.set(args.key, args.value)
+handleSettings = (request, port) ->
+ switch request.operation
+ when "get" # Get a single settings value.
+ port.postMessage key: request.key, value: Settings.get request.key
+ when "set" # Set a single settings value.
+ Settings.set request.key, request.value
+ when "fetch" # Fetch multiple settings values.
+ values = request.values
+ values[key] = Settings.get key for own key of values
+ port.postMessage { values }
refreshCompleter = (request) -> completers[request.name].refresh()