From 4c7bfb931d5c2dc0475523f4a9acc07f89a77b0f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 25 Apr 2015 16:10:59 +0100 Subject: 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). --- background_scripts/main.coffee | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'background_scripts') 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() -- cgit v1.2.3