diff options
Diffstat (limited to 'pages/options.coffee')
| -rw-r--r-- | pages/options.coffee | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/pages/options.coffee b/pages/options.coffee index 5521cc55..93b0be11 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -1,8 +1,13 @@ $ = (id) -> document.getElementById id -Settings.init() bgExclusions = chrome.extension.getBackgroundPage().Exclusions +# We have to use Settings from the background page here (not Settings, directly) to avoid a race condition for +# the page popup. Specifically, we must ensure that the settings have been updated on the background page +# *before* the popup closes. This ensures that any exclusion-rule changes are in place before the page +# regains the focus. +bgSettings = chrome.extension.getBackgroundPage().Settings + # # Class hierarchy for various types of option. class Option @@ -21,20 +26,20 @@ class Option # Fetch a setting from localStorage, remember the @previous value and populate the DOM element. # Return the fetched value. fetch: -> - @populateElement @previous = Settings.get @field + @populateElement @previous = bgSettings.get @field @previous # Write this option's new value back to localStorage, if necessary. save: -> value = @readValueFromElement() if not @areEqual value, @previous - Settings.set @field, @previous = value + bgSettings.set @field, @previous = value # Compare values; this is overridden by sub-classes. areEqual: (a,b) -> a == b restoreToDefault: -> - Settings.clear @field + bgSettings.clear @field @fetch() # Static method. |
