diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-06-16 10:22:47 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-06-18 11:53:28 +0200 |
| commit | 5453eece3a53c4cc45c8987a88789e43fb214912 (patch) | |
| tree | c36308988a46a5125949f47611e7f76cba21c27a /gui/src/renderer/components | |
| parent | 335cc80d9347f43264765a3dd359eda83c782bc8 (diff) | |
| download | mullvadvpn-5453eece3a53c4cc45c8987a88789e43fb214912.tar.xz mullvadvpn-5453eece3a53c4cc45c8987a88789e43fb214912.zip | |
Update account history RPCs
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/Login.tsx | 48 | ||||
| -rw-r--r-- | gui/src/renderer/components/Support.tsx | 4 |
2 files changed, 25 insertions, 27 deletions
diff --git a/gui/src/renderer/components/Login.tsx b/gui/src/renderer/components/Login.tsx index 6118f7ac8e..e672094f99 100644 --- a/gui/src/renderer/components/Login.tsx +++ b/gui/src/renderer/components/Login.tsx @@ -36,13 +36,13 @@ import { AriaControlGroup, AriaControlled, AriaControls } from './AriaGroup'; interface IProps { accountToken?: AccountToken; - accountHistory: AccountToken[]; + accountHistory?: AccountToken; loginState: LoginState; openExternalLink: (type: string) => void; login: (accountToken: AccountToken) => void; resetLoginError: () => void; updateAccountToken: (accountToken: AccountToken) => void; - removeAccountTokenFromHistory: (accountToken: AccountToken) => Promise<void>; + clearAccountHistory: () => Promise<void>; createNewAccount: () => void; } @@ -208,7 +208,9 @@ export default class Login extends React.Component<IProps, IState> { } private shouldShowAccountHistory() { - return this.allowInteraction() && this.state.isActive && this.props.accountHistory.length > 0; + return ( + this.allowInteraction() && this.state.isActive && this.props.accountHistory !== undefined + ); } private shouldShowFooter() { @@ -223,13 +225,13 @@ export default class Login extends React.Component<IProps, IState> { this.props.login(accountToken); }; - private onRemoveAccountFromHistory = (accountToken: string) => { - consumePromise(this.removeAccountFromHistory(accountToken)); + private onClearAccountHistory = () => { + consumePromise(this.clearAccountHistory()); }; - private async removeAccountFromHistory(accountToken: AccountToken) { + private async clearAccountHistory() { try { - await this.props.removeAccountTokenFromHistory(accountToken); + await this.props.clearAccountHistory(); // TODO: Remove account from memory } catch (error) { @@ -288,9 +290,9 @@ export default class Login extends React.Component<IProps, IState> { <Accordion expanded={this.shouldShowAccountHistory()}> <StyledAccountDropdownContainer> <AccountDropdown - items={this.props.accountHistory.slice().reverse()} + item={this.props.accountHistory} onSelect={this.onSelectAccountFromHistory} - onRemove={this.onRemoveAccountFromHistory} + onRemove={this.onClearAccountHistory} /> </StyledAccountDropdownContainer> </Accordion> @@ -316,28 +318,24 @@ export default class Login extends React.Component<IProps, IState> { } interface IAccountDropdownProps { - items: AccountToken[]; + item?: AccountToken; onSelect: (value: AccountToken) => void; onRemove: (value: AccountToken) => void; } function AccountDropdown(props: IAccountDropdownProps) { - const uniqueItems = [...new Set(props.items)]; + const token = props.item; + if (!token) { + return null; + } + const label = formatAccountToken(token); return ( - <> - {uniqueItems.map((token) => { - const label = formatAccountToken(token); - return ( - <AccountDropdownItem - key={token} - value={token} - label={label} - onSelect={props.onSelect} - onRemove={props.onRemove} - /> - ); - })} - </> + <AccountDropdownItem + value={token} + label={label} + onSelect={props.onSelect} + onRemove={props.onRemove} + /> ); } diff --git a/gui/src/renderer/components/Support.tsx b/gui/src/renderer/components/Support.tsx index e7960a30c7..d34e6b6b08 100644 --- a/gui/src/renderer/components/Support.tsx +++ b/gui/src/renderer/components/Support.tsx @@ -49,13 +49,13 @@ interface ISupportState { interface ISupportProps { defaultEmail: string; defaultMessage: string; - accountHistory: AccountToken[]; + accountHistory?: AccountToken; isOffline: boolean; onClose: () => void; viewLog: (path: string) => void; saveReportForm: (form: ISupportReportForm) => void; clearReportForm: () => void; - collectProblemReport: (accountsToRedact: string[]) => Promise<string>; + collectProblemReport: (accountToRedact?: string) => Promise<string>; sendProblemReport: (email: string, message: string, savedReportId: string) => Promise<void>; outdatedVersion: boolean; suggestedIsBeta: boolean; |
