mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 15:15:12 +08:00
Rename inbox.env
to env
, because it's not for inbox alone
This commit is contained in:
parent
a5508e46bc
commit
cce9eba509
5 changed files with 16 additions and 13 deletions
|
@ -14,7 +14,7 @@ OnboardingStore = Reflux.createStore
|
||||||
@_pageStack = [@_page]
|
@_pageStack = [@_page]
|
||||||
|
|
||||||
defaultEnv = if atom.inDevMode() then 'staging' else 'production'
|
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.setEnvironment, @_onSetEnvironment
|
||||||
@listenTo Actions.moveToPreviousPage, @_onMoveToPreviousPage
|
@listenTo Actions.moveToPreviousPage, @_onMoveToPreviousPage
|
||||||
|
@ -29,7 +29,7 @@ OnboardingStore = Reflux.createStore
|
||||||
@_error
|
@_error
|
||||||
|
|
||||||
environment: ->
|
environment: ->
|
||||||
atom.config.get('inbox.env')
|
atom.config.get('env')
|
||||||
|
|
||||||
connectType: ->
|
connectType: ->
|
||||||
@_connectType
|
@_connectType
|
||||||
|
@ -60,5 +60,5 @@ OnboardingStore = Reflux.createStore
|
||||||
|
|
||||||
_onSetEnvironment: (env) ->
|
_onSetEnvironment: (env) ->
|
||||||
throw new Error("Environment #{env} is not allowed") unless env in ['development', 'staging', 'production']
|
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()
|
@trigger()
|
||||||
|
|
|
@ -570,7 +570,9 @@ class Atom extends Model
|
||||||
@displayWindow({maximize})
|
@displayWindow({maximize})
|
||||||
|
|
||||||
@commands.add 'atom-workspace',
|
@commands.add 'atom-workspace',
|
||||||
'atom-workspace:logout': => @logout()
|
'atom-workspace:logout': =>
|
||||||
|
if atom.config.get('inbox')
|
||||||
|
@logout()
|
||||||
|
|
||||||
@commands.add 'atom-workspace',
|
@commands.add 'atom-workspace',
|
||||||
'atom-workspace:add-account': => @displayOnboardingWindow('add-account')
|
'atom-workspace:add-account': => @displayOnboardingWindow('add-account')
|
||||||
|
|
|
@ -8,12 +8,12 @@ async = require 'async'
|
||||||
class EdgehillAPI
|
class EdgehillAPI
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
atom.config.onDidChange('inbox.env', @_onConfigChanged)
|
atom.config.onDidChange('env', @_onConfigChanged)
|
||||||
@_onConfigChanged()
|
@_onConfigChanged()
|
||||||
@
|
@
|
||||||
|
|
||||||
_onConfigChanged: =>
|
_onConfigChanged: =>
|
||||||
env = atom.config.get('inbox.env')
|
env = atom.config.get('env')
|
||||||
if env is 'development'
|
if env is 'development'
|
||||||
@APIRoot = "https://edgehill-dev.nilas.com"
|
@APIRoot = "https://edgehill-dev.nilas.com"
|
||||||
else if env is 'staging'
|
else if env is 'staging'
|
||||||
|
@ -52,19 +52,21 @@ class EdgehillAPI
|
||||||
"#{root}/connect/#{provider}?login_hint=#{email_address}"
|
"#{root}/connect/#{provider}?login_hint=#{email_address}"
|
||||||
|
|
||||||
getCredentials: ->
|
getCredentials: ->
|
||||||
atom.config.get('inbox.account')
|
atom.config.get('edgehill.credentials')
|
||||||
|
|
||||||
setCredentials: (credentials) ->
|
setCredentials: (credentials) ->
|
||||||
atom.config.set('inbox.account', credentials)
|
atom.config.set('edgehill.credentials', credentials)
|
||||||
|
|
||||||
addTokens: (tokens) ->
|
addTokens: (tokens) ->
|
||||||
for token in tokens
|
for token in tokens
|
||||||
if token.provider is 'inbox'
|
if token.provider is 'inbox'
|
||||||
atom.config.set('inbox.token', token.access_token)
|
atom.config.set('inbox.token', token.access_token)
|
||||||
@setCredentials({username: token.access_token, password: ''})
|
|
||||||
if token.provider is 'salesforce'
|
if token.provider is 'salesforce'
|
||||||
atom.config.set('salesforce.token', token.access_token)
|
atom.config.set('salesforce.token', token.access_token)
|
||||||
|
|
||||||
|
if token.user_identifier?
|
||||||
|
@setCredentials({username: token.user_identifier, password: ''})
|
||||||
|
|
||||||
tokenForProvider: (provider) ->
|
tokenForProvider: (provider) ->
|
||||||
atom.config.get("#{provider}.token")
|
atom.config.get("#{provider}.token")
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class InboxAPI
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@_streamingConnections = []
|
@_streamingConnections = []
|
||||||
atom.config.onDidChange('inbox.env', @_onConfigChanged)
|
atom.config.onDidChange('env', @_onConfigChanged)
|
||||||
atom.config.onDidChange('inbox.token', @_onConfigChanged)
|
atom.config.onDidChange('inbox.token', @_onConfigChanged)
|
||||||
@_onConfigChanged()
|
@_onConfigChanged()
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class InboxAPI
|
||||||
prev = {@APIToken, @AppID, @APIRoot}
|
prev = {@APIToken, @AppID, @APIRoot}
|
||||||
|
|
||||||
@APIToken = atom.config.get('inbox.token')
|
@APIToken = atom.config.get('inbox.token')
|
||||||
env = atom.config.get('inbox.env')
|
env = atom.config.get('env')
|
||||||
if env in ['production']
|
if env in ['production']
|
||||||
@AppID = 'c96gge1jo29pl2rebcb7utsbp'
|
@AppID = 'c96gge1jo29pl2rebcb7utsbp'
|
||||||
@APIRoot = 'https://api.nilas.com'
|
@APIRoot = 'https://api.nilas.com'
|
||||||
|
|
|
@ -86,11 +86,10 @@ class InboxLongConnection
|
||||||
@_buffer = bufferJSONs[bufferJSONs.length - 1]
|
@_buffer = bufferJSONs[bufferJSONs.length - 1]
|
||||||
|
|
||||||
start: ->
|
start: ->
|
||||||
|
return if not @_inbox.APIToken?
|
||||||
return if @_state is InboxLongConnection.State.Ended
|
return if @_state is InboxLongConnection.State.Ended
|
||||||
return if @_req
|
return if @_req
|
||||||
|
|
||||||
throw (new Error 'Cannot start polling without auth token.') unless @_inbox.APIToken
|
|
||||||
|
|
||||||
console.log("Long Polling Connection: Starting....")
|
console.log("Long Polling Connection: Starting....")
|
||||||
@withCursor (cursor) =>
|
@withCursor (cursor) =>
|
||||||
return if @state is InboxLongConnection.State.Ended
|
return if @state is InboxLongConnection.State.Ended
|
||||||
|
|
Loading…
Reference in a new issue