mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 15:46:28 +08:00
fix(identity): Show number of days remaining correctly
This commit is contained in:
parent
d92dba6166
commit
3b79b4a2e0
1 changed files with 10 additions and 8 deletions
|
@ -38,7 +38,7 @@ class IdentityStore extends NylasStore {
|
||||||
|
|
||||||
this._loadIdentity();
|
this._loadIdentity();
|
||||||
|
|
||||||
if (NylasEnv.isWorkWindow() && ['staging', 'production'].includes(NylasEnv.config.get('env'))) {
|
if (NylasEnv.isMainWindow() && ['staging', 'production'].includes(NylasEnv.config.get('env'))) {
|
||||||
setInterval(this.refreshStatus, 1000 * 60 * 60);
|
setInterval(this.refreshStatus, 1000 * 60 * 60);
|
||||||
this.refreshStatus();
|
this.refreshStatus();
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,9 @@ class IdentityStore extends NylasStore {
|
||||||
this.fetchIdentity(),
|
this.fetchIdentity(),
|
||||||
Promise.all(AccountStore.accounts().map((a) =>
|
Promise.all(AccountStore.accounts().map((a) =>
|
||||||
this.fetchSubscriptionRequiredDate(a))
|
this.fetchSubscriptionRequiredDate(a))
|
||||||
).then((subscriptionRequriedDates) => {
|
).then((subscriptionRequiredDates) => {
|
||||||
this._subscriptionRequiredAfter = subscriptionRequriedDates.sort().shift();
|
this._subscriptionRequiredAfter = subscriptionRequiredDates.sort().shift();
|
||||||
|
this.trigger();
|
||||||
}),
|
}),
|
||||||
]).catch((err) => {
|
]).catch((err) => {
|
||||||
console.error(`Unable to refresh IdentityStore status: ${err.message}`)
|
console.error(`Unable to refresh IdentityStore status: ${err.message}`)
|
||||||
|
@ -161,8 +162,7 @@ class IdentityStore extends NylasStore {
|
||||||
|
|
||||||
fetchSubscriptionRequiredDate = (account) => {
|
fetchSubscriptionRequiredDate = (account) => {
|
||||||
return this.fetchPath(`/n1/account/${account.id}`).then((json) => {
|
return this.fetchPath(`/n1/account/${account.id}`).then((json) => {
|
||||||
const date = json.subscription_required_after ? new Date(json.subscription_required_after) : null;
|
return json.subscription_required_after ? new Date(json.subscription_required_after * 1000) : null;
|
||||||
Promise.resolve(date);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ class IdentityStore extends NylasStore {
|
||||||
}
|
}
|
||||||
return this.fetchPath('/n1/user').then((json) => {
|
return this.fetchPath('/n1/user').then((json) => {
|
||||||
const nextIdentity = Object.assign({}, this._identity, json);
|
const nextIdentity = Object.assign({}, this._identity, json);
|
||||||
this._onSetNylasIdentity(nextIdentity)
|
this._onSetNylasIdentity(nextIdentity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +206,10 @@ class IdentityStore extends NylasStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onSetNylasIdentity = (identity) => {
|
_onSetNylasIdentity = (identity) => {
|
||||||
|
if (identity.token) {
|
||||||
keytar.replacePassword(keytarServiceName, keytarIdentityKey, identity.token);
|
keytar.replacePassword(keytarServiceName, keytarIdentityKey, identity.token);
|
||||||
delete identity.token;
|
delete identity.token;
|
||||||
|
}
|
||||||
NylasEnv.config.set(configIdentityKey, identity);
|
NylasEnv.config.set(configIdentityKey, identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue