diff --git a/omega-target-chromium-extension/src/options.coffee b/omega-target-chromium-extension/src/options.coffee index 44cb945..ae08202 100644 --- a/omega-target-chromium-extension/src/options.coffee +++ b/omega-target-chromium-extension/src/options.coffee @@ -221,13 +221,13 @@ class ChromeOptions extends OmegaTarget.Options else Promise.reject() - getOldOptions = getOldOptions.catch -> + getOldOptions = getOldOptions.catch => if options?['config'] Promise.resolve options else if localStorage['config'] Promise.resolve localStorage else - Promise.reject new Error('No options set.') + Promise.reject new @NoOptionsError() getOldOptions.then (oldOptions) => i18n = { @@ -244,5 +244,8 @@ class ChromeOptions extends OmegaTarget.Options @_state.set({'firstRun': 'upgrade'}) return this && super(upgraded, upgraded) + onFirstRun: (reason) -> + chrome.tabs.create url: chrome.extension.getURL('options.html') + module.exports = ChromeOptions diff --git a/omega-target/src/options.coffee b/omega-target/src/options.coffee index fed0414..f5fea4d 100644 --- a/omega-target/src/options.coffee +++ b/omega-target/src/options.coffee @@ -34,6 +34,8 @@ class Options constructor: (@profileName) -> super.constructor("Profile #{@profileName} does not exist!") + NoOptionsError: class NoOptionsError extends Error + constructor: (@_options, @_storage, @_state, @log) -> @_storage ?= Storage() @_state ?= Storage() @@ -55,7 +57,8 @@ class Options @_storage.remove(removed) ).return(options) ).catch (ex) => - @log.error(ex.stack) + if not ex instanceof NoOptionsError + @log.error(ex.stack) @reset().tap => @_state.set({'firstRun': 'new', 'web.switchGuide': 'showOnFirstUse'}) ).then((options) => @@ -82,6 +85,10 @@ class Options ).then => @getAll() @ready.then => + @_state.get({'firstRun': ''}).then ({firstRun}) => + if firstRun + @onFirstRun(firstRun) + if @_options['-downloadInterval'] > 0 @updateProfile() @@ -156,6 +163,12 @@ class Options @_storage.set(opt) ).then -> opt + ###* + # Called on the first initialization of options. + # @param {reason} reason The value of 'firstRun' in state. + ### + onFirstRun: (reason) -> null + ###* # Return the default options used initially and on resets. # @returns {?OmegaOptions} The default options.