mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -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
|
||||
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
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user