diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-21 07:49:28 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-24 08:39:30 -0300 |
| commit | 0420e721ab9b6743510979faf442a27ff757ceee (patch) | |
| tree | 8c32cae0f18c98d8cc05a5759a7e5c8c3ae3fa69 | |
| parent | 66ba3a0dff2e660cda34f98fb8547e7b7327321c (diff) | |
| download | mullvadvpn-0420e721ab9b6743510979faf442a27ff757ceee.tar.xz mullvadvpn-0420e721ab9b6743510979faf442a27ff757ceee.zip | |
Invalidate account cache if account token changes
| -rw-r--r-- | gui/packages/desktop/src/renderer/app.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js index c65906d010..e973340107 100644 --- a/gui/packages/desktop/src/renderer/app.js +++ b/gui/packages/desktop/src/renderer/app.js @@ -615,6 +615,7 @@ type AccountVerification = // An account data cache that helps to throttle RPC requests to get_account_data and retain the // cached value for 1 minute. class AccountDataCache { + _currentAccount: ?AccountToken; _executingPromise: ?Promise<AccountData>; _value: ?AccountData; _expiresAt: ?Date; @@ -625,6 +626,12 @@ class AccountDataCache { } async fetch(accountToken: AccountToken): Promise<AccountData> { + // invalidate cache if account token has changed + if (accountToken !== this._currentAccount) { + this.invalidate(); + this._currentAccount = accountToken; + } + // return the same promise if still fetching from remote const executingPromise = this._executingPromise; if (executingPromise) { |
