diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-02-21 15:31:52 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-02-21 15:31:52 +0100 |
| commit | a558bbbed062059dc778d78c4f179945deb5ef41 (patch) | |
| tree | b6a77e46fc0f3ee3aa4886d2d33ce147bfc8996b /gui/src/renderer | |
| parent | af69985becd9a4fd8f2b80d57dc568a0cf7d0ce5 (diff) | |
| parent | e260455ac88de2c641d5df11af9d2fd38b047fe0 (diff) | |
| download | mullvadvpn-a558bbbed062059dc778d78c4f179945deb5ef41.tar.xz mullvadvpn-a558bbbed062059dc778d78c4f179945deb5ef41.zip | |
Merge branch 'eslint-add-promise-rules'
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/app.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/components/Accordion.tsx | 5 | ||||
| -rw-r--r-- | gui/src/renderer/components/AppButton.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/components/Login.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/components/Marquee.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/NotificationBanner.tsx | 5 | ||||
| -rw-r--r-- | gui/src/renderer/containers/AccountPage.tsx | 3 | ||||
| -rw-r--r-- | gui/src/renderer/containers/LoginPage.tsx | 3 | ||||
| -rw-r--r-- | gui/src/renderer/containers/PreferencesPage.tsx | 3 |
9 files changed, 28 insertions, 20 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 73de4302bf..9eabd147b5 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -27,6 +27,7 @@ import { loadTranslations, messages, relayLocations } from '../shared/gettext'; import { IGuiSettingsState, SYSTEM_PREFERRED_LOCALE_KEY } from '../shared/gui-settings-state'; import { IpcRendererEventChannel, IRelayListPair } from '../shared/ipc-event-channel'; import { getRendererLogFile, setupLogging } from '../shared/logging'; +import consumePromise from '../shared/promise'; import { AccountToken, @@ -121,7 +122,7 @@ export default class AppRenderer { }); IpcRendererEventChannel.daemonConnected.listen(() => { - this.onDaemonConnected(); + consumePromise(this.onDaemonConnected()); }); IpcRendererEventChannel.daemonDisconnected.listen((errorMessage?: string) => { @@ -206,7 +207,7 @@ export default class AppRenderer { this.setWireguardPublicKey(initialState.wireguardPublicKey); if (initialState.isConnected) { - this.onDaemonConnected(); + consumePromise(this.onDaemonConnected()); } // disable pinch to zoom @@ -290,7 +291,7 @@ export default class AppRenderer { return IpcRendererEventChannel.settings.updateBridgeSettings(bridgeSettings); } - public async removeAccountFromHistory(accountToken: AccountToken): Promise<void> { + public removeAccountFromHistory(accountToken: AccountToken): Promise<void> { return IpcRendererEventChannel.accountHistory.removeItem(accountToken); } @@ -301,7 +302,7 @@ export default class AppRenderer { } catch (e) { log.error(`Failed to get the WWW auth token: ${e.message}`); } - shell.openExternal(`${link}?token=${token}`); + consumePromise(shell.openExternal(`${link}?token=${token}`)); } public async setAllowLan(allowLan: boolean) { diff --git a/gui/src/renderer/components/Accordion.tsx b/gui/src/renderer/components/Accordion.tsx index 19c9ddee56..cf6603774e 100644 --- a/gui/src/renderer/components/Accordion.tsx +++ b/gui/src/renderer/components/Accordion.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import { Animated, Component, Styles, Types, UserInterface, View } from 'reactxp'; +import consumePromise from '../../shared/promise'; interface IProps { expanded: boolean; @@ -56,11 +57,11 @@ export default class Accordion extends Component<IProps, IState> { if (this.props.expanded && !this.state.mountChildren) { this.setState({ mountChildren: true }); } else { - this.animate(this.props.expanded); + consumePromise(this.animate(this.props.expanded)); } } else if (this.state.mountChildren && !oldState.mountChildren) { // run animations once the children are mounted - this.animate(this.props.expanded); + consumePromise(this.animate(this.props.expanded)); } } diff --git a/gui/src/renderer/components/AppButton.tsx b/gui/src/renderer/components/AppButton.tsx index d31194e072..e1c37c014b 100644 --- a/gui/src/renderer/components/AppButton.tsx +++ b/gui/src/renderer/components/AppButton.tsx @@ -2,6 +2,7 @@ import log from 'electron-log'; import * as React from 'react'; import { Button, Component, Styles, Text, Types, UserInterface, View } from 'reactxp'; import { colors } from '../../config.json'; +import consumePromise from '../../shared/promise'; import styles from './AppButtonStyles'; import ImageView from './ImageView'; @@ -94,7 +95,7 @@ class BaseButton extends Component<IProps, IState> { private textViewRef = React.createRef<PrivateLabel>(); public componentDidMount() { - this.forceUpdateTextAdjustment(); + consumePromise(this.forceUpdateTextAdjustment()); } public render() { @@ -135,7 +136,7 @@ class BaseButton extends Component<IProps, IState> { this, ); - this.updateTextAdjustment(containerLayout); + await this.updateTextAdjustment(containerLayout); } } @@ -160,8 +161,8 @@ class BaseButton extends Component<IProps, IState> { } } - private onLayout = async (containerLayout: Types.ViewOnLayoutEvent) => { - this.updateTextAdjustment(containerLayout); + private onLayout = (containerLayout: Types.ViewOnLayoutEvent) => { + consumePromise(this.updateTextAdjustment(containerLayout)); }; } diff --git a/gui/src/renderer/components/Login.tsx b/gui/src/renderer/components/Login.tsx index 9e2ff82433..f49054f076 100644 --- a/gui/src/renderer/components/Login.tsx +++ b/gui/src/renderer/components/Login.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { Animated, Component, Styles, Text, TextInput, Types, UserInterface, View } from 'reactxp'; import { colors, links } from '../../config.json'; +import consumePromise from '../../shared/promise'; import { messages } from '../../shared/gettext'; import Accordion from './Accordion'; import * as AppButton from './AppButton'; @@ -72,7 +73,7 @@ export default class Login extends Component<IProps, IState> { } public componentDidMount() { - this.setFooterVisibility(this.shouldShowFooter()); + consumePromise(this.setFooterVisibility(this.shouldShowFooter())); } public componentDidUpdate(prevProps: IProps, _prevState: IState) { @@ -91,7 +92,7 @@ export default class Login extends Component<IProps, IState> { } this.setLoginButtonActive(this.shouldActivateLoginButton()); - this.setFooterVisibility(this.shouldShowFooter()); + consumePromise(this.setFooterVisibility(this.shouldShowFooter())); } public render() { @@ -142,7 +143,7 @@ export default class Login extends Component<IProps, IState> { this.setState({ isActive: false }); }; - private async setLoginButtonActive(isActive: boolean) { + private setLoginButtonActive(isActive: boolean) { if (this.isLoginButtonActive === isActive) { return; } @@ -336,7 +337,7 @@ export default class Login extends Component<IProps, IState> { }; private onRemoveAccountFromHistory = (accountToken: string) => { - this.removeAccountFromHistory(accountToken); + consumePromise(this.removeAccountFromHistory(accountToken)); }; private async removeAccountFromHistory(accountToken: AccountToken) { diff --git a/gui/src/renderer/components/Marquee.tsx b/gui/src/renderer/components/Marquee.tsx index dc019d74ca..04b095711e 100644 --- a/gui/src/renderer/components/Marquee.tsx +++ b/gui/src/renderer/components/Marquee.tsx @@ -45,7 +45,7 @@ export default class Marquee extends Component<IMarqueeProps> { ); } - private async startAnimation() { + private startAnimation() { this.stopAnimation(); this.animationTimeout = setTimeout(async () => { diff --git a/gui/src/renderer/components/NotificationBanner.tsx b/gui/src/renderer/components/NotificationBanner.tsx index ba626c07f4..360c910403 100644 --- a/gui/src/renderer/components/NotificationBanner.tsx +++ b/gui/src/renderer/components/NotificationBanner.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { Animated, Button, Component, Styles, Text, Types, UserInterface, View } from 'reactxp'; import { colors } from '../../config.json'; +import consumePromise from '../../shared/promise'; import { BlockingButton } from './AppButton'; import ImageView from './ImageView'; @@ -213,7 +214,7 @@ export class NotificationBanner extends Component< if (prevProps.visible !== this.props.visible) { // enable drawer-like animation when changing banner's visibility this.setState({ contentPinnedToBottom: true }, () => { - this.animateHeightChanges(); + consumePromise(this.animateHeightChanges()); }); } } @@ -249,7 +250,7 @@ export class NotificationBanner extends Component< // notification banner to slide down each time the component is mounted. if (this.didFinishFirstLayoutPass) { if (oldHeight !== height) { - this.animateHeightChanges(); + consumePromise(this.animateHeightChanges()); } } else { this.didFinishFirstLayoutPass = true; diff --git a/gui/src/renderer/containers/AccountPage.tsx b/gui/src/renderer/containers/AccountPage.tsx index 945512a2f7..012427b94d 100644 --- a/gui/src/renderer/containers/AccountPage.tsx +++ b/gui/src/renderer/containers/AccountPage.tsx @@ -2,6 +2,7 @@ import { goBack } from 'connected-react-router'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { links } from '../../config.json'; +import consumePromise from '../../shared/promise'; import Account from '../components/Account'; import withAppContext, { IAppContext } from '../context'; @@ -17,7 +18,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IAppContext) => { const history = bindActionCreators({ goBack }, dispatch); return { onLogout: () => { - props.app.logout(); + consumePromise(props.app.logout()); }, onClose: () => { history.goBack(); diff --git a/gui/src/renderer/containers/LoginPage.tsx b/gui/src/renderer/containers/LoginPage.tsx index 9b39520881..2f221ad875 100644 --- a/gui/src/renderer/containers/LoginPage.tsx +++ b/gui/src/renderer/containers/LoginPage.tsx @@ -2,6 +2,7 @@ import { push } from 'connected-react-router'; import { shell } from 'electron'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import consumePromise from '../../shared/promise'; import Login from '../components/Login'; import withAppContext, { IAppContext } from '../context'; import accountActions from '../redux/account/actions'; @@ -24,7 +25,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IAppContext) => { history.push('/settings'); }, login: (account: string) => { - props.app.login(account); + consumePromise(props.app.login(account)); }, resetLoginError: () => { resetLoginError(); diff --git a/gui/src/renderer/containers/PreferencesPage.tsx b/gui/src/renderer/containers/PreferencesPage.tsx index 068f6f8d1d..299d5799cb 100644 --- a/gui/src/renderer/containers/PreferencesPage.tsx +++ b/gui/src/renderer/containers/PreferencesPage.tsx @@ -2,6 +2,7 @@ import { goBack } from 'connected-react-router'; import log from 'electron-log'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import consumePromise from '../../shared/promise'; import Preferences from '../components/Preferences'; import withAppContext, { IAppContext } from '../context'; import { IReduxState, ReduxDispatch } from '../redux/store'; @@ -35,7 +36,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IAppContext) => { props.app.setAutoConnect(autoConnect); }, setAllowLan: (allowLan: boolean) => { - props.app.setAllowLan(allowLan); + consumePromise(props.app.setAllowLan(allowLan)); }, setStartMinimized: (startMinimized: boolean) => { props.app.setStartMinimized(startMinimized); |
