mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-20 22:23:53 +08:00
fix(onboarding): use proper env
This commit is contained in:
parent
e5ca74684d
commit
077472af55
3 changed files with 35 additions and 15 deletions
|
@ -67,16 +67,10 @@ export function buildGmailAuthURL(sessionKey) {
|
|||
});
|
||||
}
|
||||
|
||||
export function buildWelcomeURL() {
|
||||
export function buildWelcomeURL(welcomeRoot) {
|
||||
const identity = IdentityStore.identity();
|
||||
if (!identity) { NylasEnv.reportError(new Error("Can't find Nylas ID")) }
|
||||
return url.format({
|
||||
protocol: 'https',
|
||||
host: 'nylas.com/welcome',
|
||||
query: {
|
||||
n: base64url(identity.id),
|
||||
},
|
||||
});
|
||||
return `${welcomeRoot}/welcome?n=${base64url(identity.id)}`
|
||||
}
|
||||
|
||||
export function runAuthRequest(accountInfo) {
|
||||
|
|
|
@ -18,6 +18,9 @@ class OnboardingStore extends NylasStore {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
NylasEnv.config.onDidChange('env', this._onEnvChanged);
|
||||
this._onEnvChanged();
|
||||
|
||||
this.listenTo(OnboardingActions.moveToPreviousPage, this._onMoveToPreviousPage)
|
||||
this.listenTo(OnboardingActions.moveToPage, this._onMoveToPage)
|
||||
this.listenTo(OnboardingActions.accountJSONReceived, this._onAccountJSONReceived)
|
||||
|
@ -51,6 +54,19 @@ class OnboardingStore extends NylasStore {
|
|||
}
|
||||
}
|
||||
|
||||
_onEnvChanged = () => {
|
||||
const env = NylasEnv.config.get('env')
|
||||
if (['development', 'local'].includes(env)) {
|
||||
this.welcomeRoot = "http://0.0.0.0:5555";
|
||||
} else if (env === 'experimental') {
|
||||
this.welcomeRoot = "https://www-experimental.nylas.com";
|
||||
} else if (env === 'staging') {
|
||||
this.welcomeRoot = "https://www-staging.nylas.com";
|
||||
} else {
|
||||
this.welcomeRoot = "https://nylas.com";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User hits nylas.com for the first time and is given cookieId
|
||||
* All events must now be associated with cookieId or its current
|
||||
|
@ -61,7 +77,7 @@ class OnboardingStore extends NylasStore {
|
|||
*/
|
||||
_openWelcomePage() {
|
||||
// open the external welcome page
|
||||
const url = buildWelcomeURL(this._accountFromAuth);
|
||||
const url = buildWelcomeURL(this.welcomeRoot);
|
||||
shell.openExternal(url, {activate: false});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ const configIdentityKey = "nylas.identity";
|
|||
const keytarServiceName = 'Nylas';
|
||||
const keytarIdentityKey = 'Nylas Account';
|
||||
|
||||
const URLRoot = "https://billing-staging.nylas.com";
|
||||
|
||||
const State = {
|
||||
Trialing: 'Trialing',
|
||||
Valid: 'Valid',
|
||||
|
@ -23,6 +21,9 @@ class IdentityStore extends NylasStore {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
NylasEnv.config.onDidChange('env', this._onEnvChanged);
|
||||
this._onEnvChanged();
|
||||
|
||||
this.listenTo(AccountStore, () => { this.trigger() });
|
||||
this.listenTo(Actions.setNylasIdentity, this._onSetNylasIdentity);
|
||||
this.listenTo(Actions.logoutNylasIdentity, this._onLogoutNylasIdentity);
|
||||
|
@ -40,6 +41,19 @@ class IdentityStore extends NylasStore {
|
|||
}
|
||||
}
|
||||
|
||||
_onEnvChanged = () => {
|
||||
const env = NylasEnv.config.get('env')
|
||||
if (['development', 'local'].includes(env)) {
|
||||
this.URLRoot = "http://localhost:5009";
|
||||
} else if (env === 'experimental') {
|
||||
this.URLRoot = "https://billing-experimental.nylas.com";
|
||||
} else if (env === 'staging') {
|
||||
this.URLRoot = "https://billing-staging.nylas.com";
|
||||
} else {
|
||||
this.URLRoot = "https://billing.nylas.com";
|
||||
}
|
||||
}
|
||||
|
||||
_loadIdentity() {
|
||||
this._identity = NylasEnv.config.get(configIdentityKey);
|
||||
if (this._identity) {
|
||||
|
@ -51,10 +65,6 @@ class IdentityStore extends NylasStore {
|
|||
return State;
|
||||
}
|
||||
|
||||
get URLRoot() {
|
||||
return URLRoot;
|
||||
}
|
||||
|
||||
identity() {
|
||||
return this._identity;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue