diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-07-06 19:26:35 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-07-08 13:23:30 +0200 |
| commit | 1592932fe5c09e1f359c63fb25ed9899b356007f (patch) | |
| tree | 29e9d0c193b88ef1f45f54d8a4321e2645382972 | |
| parent | 8452dc8559837253b253df7f47a075f156845e66 (diff) | |
| download | mullvadvpn-1592932fe5c09e1f359c63fb25ed9899b356007f.tar.xz mullvadvpn-1592932fe5c09e1f359c63fb25ed9899b356007f.zip | |
Fetch account data when settings and account page is mounted
| -rw-r--r-- | gui/src/main/index.ts | 1 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/components/Account.tsx | 5 | ||||
| -rw-r--r-- | gui/src/renderer/components/Settings.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/containers/AccountPage.tsx | 1 | ||||
| -rw-r--r-- | gui/src/renderer/containers/SettingsPage.tsx | 1 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 1 |
7 files changed, 22 insertions, 0 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index d7036a508c..fc7903a04f 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -1180,6 +1180,7 @@ class ApplicationMain { return response; }); + IpcMainEventChannel.account.handleUpdateData(() => this.updateAccountData()); IpcMainEventChannel.accountHistory.handleClear(async () => { await this.daemonRpc.clearAccountHistory(); diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 677286c092..febcaf8bc8 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -318,6 +318,10 @@ export default class AppRenderer { return IpcRendererEventChannel.account.submitVoucher(voucherCode); } + public updateAccountData(): void { + IpcRendererEventChannel.account.updateData(); + } + public async connectTunnel(): Promise<void> { const state = this.tunnelState.state; diff --git a/gui/src/renderer/components/Account.tsx b/gui/src/renderer/components/Account.tsx index 18980ca1a9..02e2b9f081 100644 --- a/gui/src/renderer/components/Account.tsx +++ b/gui/src/renderer/components/Account.tsx @@ -31,9 +31,14 @@ interface IProps { onLogout: () => void; onClose: () => void; onBuyMore: () => Promise<void>; + updateAccountData: () => void; } export default class Account extends React.Component<IProps> { + public componentDidMount() { + this.props.updateAccountData(); + } + public render() { return ( <ModalContainer> diff --git a/gui/src/renderer/components/Settings.tsx b/gui/src/renderer/components/Settings.tsx index 56b8fd5494..1610f776f9 100644 --- a/gui/src/renderer/components/Settings.tsx +++ b/gui/src/renderer/components/Settings.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { colors, links } from '../../config.json'; import { hasExpired, formatRemainingTime } from '../../shared/account-expiry'; import { messages } from '../../shared/gettext'; +import History from '../lib/history'; import { AriaDescribed, AriaDescription, AriaDescriptionGroup } from './AriaGroup'; import * as Cell from './cell'; import { Layout } from './Layout'; @@ -42,9 +43,17 @@ export interface IProps { onViewPreferences: () => void; onViewAdvancedSettings: () => void; onExternalLink: (url: string) => void; + updateAccountData: () => void; + history: History; } export default class Settings extends React.Component<IProps> { + public componentDidMount() { + if (this.props.history.action === 'PUSH') { + this.props.updateAccountData(); + } + } + public render() { const showLargeTitle = this.props.loginState.type !== 'ok'; diff --git a/gui/src/renderer/containers/AccountPage.tsx b/gui/src/renderer/containers/AccountPage.tsx index 985161c838..8751107c74 100644 --- a/gui/src/renderer/containers/AccountPage.tsx +++ b/gui/src/renderer/containers/AccountPage.tsx @@ -22,6 +22,7 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp props.history.pop(); }, onBuyMore: () => props.app.openLinkWithAuth(links.purchase), + updateAccountData: () => props.app.updateAccountData(), }; }; diff --git a/gui/src/renderer/containers/SettingsPage.tsx b/gui/src/renderer/containers/SettingsPage.tsx index 97ff917e7e..57ded8cd24 100644 --- a/gui/src/renderer/containers/SettingsPage.tsx +++ b/gui/src/renderer/containers/SettingsPage.tsx @@ -26,6 +26,7 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp onViewPreferences: () => props.history.push('/settings/preferences'), onViewAdvancedSettings: () => props.history.push('/settings/advanced'), onExternalLink: (url: string) => props.app.openUrl(url), + updateAccountData: () => props.app.updateAccountData(), }; }; diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index 5789bcc149..e2b3ebbed3 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -164,6 +164,7 @@ export const ipcSchema = { logout: invoke<void, void>(), getWwwAuthToken: invoke<void, string>(), submitVoucher: invoke<string, VoucherResponse>(), + updateData: send<void>(), }, accountHistory: { '': notifyRenderer<AccountToken | undefined>(), |
