From db65721aa67b2de75b1e279f01e721676e83b448 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 27 Apr 2014 11:52:30 +0100 Subject: Response to @philc's comments regarding sync. --- background_scripts/settings.coffee | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'background_scripts/settings.coffee') diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index f75c1db3..73a7a04b 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -23,10 +23,9 @@ root.Settings = Settings = has: (key) -> key of localStorage - # postUpdateHooks are called each time an option changes: - # either from options/options.coffee (when the options page is saved) - # or from background_scripts/sync.coffee (when an update propagates from chrome.storage) - # + # for settings which require action when their value changes, add hooks here + # called from options/options.coffee (when the options page is saved), and from background_scripts/sync.coffee (when + # an update propagates from chrome.storage.sync). postUpdateHooks: keyMappings: (value) -> root.Commands.clearKeyMappingsAndSetDefaults() @@ -34,10 +33,8 @@ root.Settings = Settings = root.refreshCompletionKeysAfterMappingSave() # postUpdateHooks convenience wrapper - doPostUpdateHook: (key, value) -> - if @postUpdateHooks[key] - @postUpdateHooks[key] value - + performPostUpdateHook: (key, value) -> + @postUpdateHooks[key] value if @postUpdateHooks[key] # options/options.(coffee|html) only handle booleans and strings; therefore # all defaults must be booleans or strings -- cgit v1.2.3