mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 23:08:13 -05:00
Show options page on first run.
This commit is contained in:
parent
25f27dd1ee
commit
e2133b3962
@ -221,13 +221,13 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
else
|
else
|
||||||
Promise.reject()
|
Promise.reject()
|
||||||
|
|
||||||
getOldOptions = getOldOptions.catch ->
|
getOldOptions = getOldOptions.catch =>
|
||||||
if options?['config']
|
if options?['config']
|
||||||
Promise.resolve options
|
Promise.resolve options
|
||||||
else if localStorage['config']
|
else if localStorage['config']
|
||||||
Promise.resolve localStorage
|
Promise.resolve localStorage
|
||||||
else
|
else
|
||||||
Promise.reject new Error('No options set.')
|
Promise.reject new @NoOptionsError()
|
||||||
|
|
||||||
getOldOptions.then (oldOptions) =>
|
getOldOptions.then (oldOptions) =>
|
||||||
i18n = {
|
i18n = {
|
||||||
@ -244,5 +244,8 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
@_state.set({'firstRun': 'upgrade'})
|
@_state.set({'firstRun': 'upgrade'})
|
||||||
return this && super(upgraded, upgraded)
|
return this && super(upgraded, upgraded)
|
||||||
|
|
||||||
|
onFirstRun: (reason) ->
|
||||||
|
chrome.tabs.create url: chrome.extension.getURL('options.html')
|
||||||
|
|
||||||
module.exports = ChromeOptions
|
module.exports = ChromeOptions
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ class Options
|
|||||||
constructor: (@profileName) ->
|
constructor: (@profileName) ->
|
||||||
super.constructor("Profile #{@profileName} does not exist!")
|
super.constructor("Profile #{@profileName} does not exist!")
|
||||||
|
|
||||||
|
NoOptionsError: class NoOptionsError extends Error
|
||||||
|
|
||||||
constructor: (@_options, @_storage, @_state, @log) ->
|
constructor: (@_options, @_storage, @_state, @log) ->
|
||||||
@_storage ?= Storage()
|
@_storage ?= Storage()
|
||||||
@_state ?= Storage()
|
@_state ?= Storage()
|
||||||
@ -55,6 +57,7 @@ class Options
|
|||||||
@_storage.remove(removed)
|
@_storage.remove(removed)
|
||||||
).return(options)
|
).return(options)
|
||||||
).catch (ex) =>
|
).catch (ex) =>
|
||||||
|
if not ex instanceof NoOptionsError
|
||||||
@log.error(ex.stack)
|
@log.error(ex.stack)
|
||||||
@reset().tap =>
|
@reset().tap =>
|
||||||
@_state.set({'firstRun': 'new', 'web.switchGuide': 'showOnFirstUse'})
|
@_state.set({'firstRun': 'new', 'web.switchGuide': 'showOnFirstUse'})
|
||||||
@ -82,6 +85,10 @@ class Options
|
|||||||
).then => @getAll()
|
).then => @getAll()
|
||||||
|
|
||||||
@ready.then =>
|
@ready.then =>
|
||||||
|
@_state.get({'firstRun': ''}).then ({firstRun}) =>
|
||||||
|
if firstRun
|
||||||
|
@onFirstRun(firstRun)
|
||||||
|
|
||||||
if @_options['-downloadInterval'] > 0
|
if @_options['-downloadInterval'] > 0
|
||||||
@updateProfile()
|
@updateProfile()
|
||||||
|
|
||||||
@ -156,6 +163,12 @@ class Options
|
|||||||
@_storage.set(opt)
|
@_storage.set(opt)
|
||||||
).then -> 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.
|
# Return the default options used initially and on resets.
|
||||||
# @returns {?OmegaOptions} The default options.
|
# @returns {?OmegaOptions} The default options.
|
||||||
|
Loading…
Reference in New Issue
Block a user