aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-04-25 16:10:59 +0100
committerStephen Blott2015-04-25 16:11:01 +0100
commit4c7bfb931d5c2dc0475523f4a9acc07f89a77b0f (patch)
treeddeb20c1712fc757ea308bc4284174e6551cb114 /background_scripts
parentd0ca0745dc6b1818d2197ff51b0ed4d90fb6bc64 (diff)
downloadvimium-4c7bfb931d5c2dc0475523f4a9acc07f89a77b0f.tar.bz2
Simplify front-end settings logic.
- Simplify the settings logic. - Send a single request for all required settings (instead of 12 inidividual requests for the 12 settings values we need in the front end).
Diffstat (limited to 'background_scripts')
-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()