Rename inbox.env to env, because it's not for inbox alone

This commit is contained in:
Ben Gotow 2015-03-05 10:58:16 -08:00
parent a5508e46bc
commit cce9eba509
5 changed files with 16 additions and 13 deletions

View file

@ -14,7 +14,7 @@ OnboardingStore = Reflux.createStore
@_pageStack = [@_page]
defaultEnv = if atom.inDevMode() then 'staging' else 'production'
atom.config.set('inbox.env', defaultEnv) unless atom.config.get('inbox.env')
atom.config.set('env', defaultEnv) unless atom.config.get('env')
@listenTo Actions.setEnvironment, @_onSetEnvironment
@listenTo Actions.moveToPreviousPage, @_onMoveToPreviousPage
@ -29,7 +29,7 @@ OnboardingStore = Reflux.createStore
@_error
environment: ->
atom.config.get('inbox.env')
atom.config.get('env')
connectType: ->
@_connectType
@ -60,5 +60,5 @@ OnboardingStore = Reflux.createStore
_onSetEnvironment: (env) ->
throw new Error("Environment #{env} is not allowed") unless env in ['development', 'staging', 'production']
atom.config.set('inbox.env', env)
atom.config.set('env', env)
@trigger()

View file

@ -570,7 +570,9 @@ class Atom extends Model
@displayWindow({maximize})
@commands.add 'atom-workspace',
'atom-workspace:logout': => @logout()
'atom-workspace:logout': =>
if atom.config.get('inbox')
@logout()
@commands.add 'atom-workspace',
'atom-workspace:add-account': => @displayOnboardingWindow('add-account')

View file

@ -8,12 +8,12 @@ async = require 'async'
class EdgehillAPI
constructor: ->
atom.config.onDidChange('inbox.env', @_onConfigChanged)
atom.config.onDidChange('env', @_onConfigChanged)
@_onConfigChanged()
@
_onConfigChanged: =>
env = atom.config.get('inbox.env')
env = atom.config.get('env')
if env is 'development'
@APIRoot = "https://edgehill-dev.nilas.com"
else if env is 'staging'
@ -52,19 +52,21 @@ class EdgehillAPI
"#{root}/connect/#{provider}?login_hint=#{email_address}"
getCredentials: ->
atom.config.get('inbox.account')
atom.config.get('edgehill.credentials')
setCredentials: (credentials) ->
atom.config.set('inbox.account', credentials)
atom.config.set('edgehill.credentials', credentials)
addTokens: (tokens) ->
for token in tokens
if token.provider is 'inbox'
atom.config.set('inbox.token', token.access_token)
@setCredentials({username: token.access_token, password: ''})
if token.provider is 'salesforce'
atom.config.set('salesforce.token', token.access_token)
if token.user_identifier?
@setCredentials({username: token.user_identifier, password: ''})
tokenForProvider: (provider) ->
atom.config.get("#{provider}.token")

View file

@ -12,7 +12,7 @@ class InboxAPI
constructor: ->
@_streamingConnections = []
atom.config.onDidChange('inbox.env', @_onConfigChanged)
atom.config.onDidChange('env', @_onConfigChanged)
atom.config.onDidChange('inbox.token', @_onConfigChanged)
@_onConfigChanged()
@ -24,7 +24,7 @@ class InboxAPI
prev = {@APIToken, @AppID, @APIRoot}
@APIToken = atom.config.get('inbox.token')
env = atom.config.get('inbox.env')
env = atom.config.get('env')
if env in ['production']
@AppID = 'c96gge1jo29pl2rebcb7utsbp'
@APIRoot = 'https://api.nilas.com'

View file

@ -86,11 +86,10 @@ class InboxLongConnection
@_buffer = bufferJSONs[bufferJSONs.length - 1]
start: ->
return if not @_inbox.APIToken?
return if @_state is InboxLongConnection.State.Ended
return if @_req
throw (new Error 'Cannot start polling without auth token.') unless @_inbox.APIToken
console.log("Long Polling Connection: Starting....")
@withCursor (cursor) =>
return if @state is InboxLongConnection.State.Ended