diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/components/AdvancedSettings.js | 32 | ||||
| -rw-r--r-- | app/components/HeaderBar.js | 5 | ||||
| -rw-r--r-- | app/components/Img.js | 4 | ||||
| -rw-r--r-- | app/components/Layout.js | 21 | ||||
| -rw-r--r-- | app/components/Preferences.js | 4 | ||||
| -rw-r--r-- | app/containers/LoginPage.js | 4 | ||||
| -rw-r--r-- | app/containers/SelectLocationPage.js | 4 | ||||
| -rw-r--r-- | app/containers/SettingsPage.js | 11 | ||||
| -rw-r--r-- | app/containers/SupportPage.js | 4 |
9 files changed, 46 insertions, 43 deletions
diff --git a/app/components/AdvancedSettings.js b/app/components/AdvancedSettings.js index eca00a4da1..ed865036e1 100644 --- a/app/components/AdvancedSettings.js +++ b/app/components/AdvancedSettings.js @@ -8,14 +8,14 @@ import CustomScrollbars from './CustomScrollbars'; import styles from './AdvancedSettingsStyles'; import Img from './Img'; -export class AdvancedSettings extends Component { - props: { - protocol: string, - port: string | number, - onUpdate: (protocol: string, port: string | number) => void, - onClose: () => void, - }; +type AdvancedSettingsProps = { + protocol: string, + port: string | number, + onUpdate: (protocol: string, port: string | number) => void, + onClose: () => void, +}; +export class AdvancedSettings extends Component<AdvancedSettingsProps> { render() { let portSelector = null; let protocol = this.props.protocol.toUpperCase(); @@ -64,14 +64,18 @@ export class AdvancedSettings extends Component { } } -class Selector extends Component { - props: { - title: string, - values: Array<*>, - value: *, - onSelect: (*) => void, - }; +type SelectorProps<T> = { + title: string, + values: Array<T>, + value: T, + onSelect: (T) => void, +}; + +type SelectorState = { + hoveredButtonIndex: number, +}; +class Selector extends Component<SelectorProps<*>, SelectorState> { state = { hoveredButtonIndex: -1 }; handleButtonHover = (value) => { diff --git a/app/components/HeaderBar.js b/app/components/HeaderBar.js index 4472b05dcc..69578bacfa 100644 --- a/app/components/HeaderBar.js +++ b/app/components/HeaderBar.js @@ -15,9 +15,8 @@ export type HeaderBarProps = { onSettings: ?() => void, }; -export default class HeaderBar extends Component { - props: HeaderBarProps; - static defaultProps: $Shape<HeaderBarProps> = { +export default class HeaderBar extends Component<HeaderBarProps> { + static defaultProps: HeaderBarProps = { style: 'default', hidden: false, showSettings: false, diff --git a/app/components/Img.js b/app/components/Img.js index fb74ac9fe6..1d6f6613f4 100644 --- a/app/components/Img.js +++ b/app/components/Img.js @@ -2,7 +2,7 @@ import * as React from 'react'; import { View, Component, Types } from 'reactxp'; -type ImgProps = { +type Props = { source: string, tintColor?: string, hoverStyle?: Types.ViewStyle, @@ -11,7 +11,7 @@ type ImgProps = { type State = { hovered: boolean }; -export default class Img extends Component<ImgProps, State> { +export default class Img extends Component<Props, State> { state = { hovered: false }; onHoverStart = () => (!this.props.disabled ? this.setState({ hovered: true }) : null); diff --git a/app/components/Layout.js b/app/components/Layout.js index 23d8e7c20c..2699b3e43d 100644 --- a/app/components/Layout.js +++ b/app/components/Layout.js @@ -7,8 +7,7 @@ import type { HeaderBarProps } from './HeaderBar'; import styles from './LayoutStyles'; -export class Header extends Component { - props: HeaderBarProps; +export class Header extends Component<HeaderBarProps> { static defaultProps = HeaderBar.defaultProps; render() { @@ -20,21 +19,19 @@ export class Header extends Component { } } -export class Container extends Component { - props: { - children: React.Node, - }; - +type ContainerProps = { + children: React.Node, +}; +export class Container extends Component<ContainerProps> { render() { return <View style={styles.container}>{this.props.children}</View>; } } -export class Layout extends Component { - props: { - children: Array<React.Node> | React.Node, - }; - +type LayoutProps = { + children: Array<React.Node> | React.Node, +}; +export class Layout extends Component<LayoutProps> { render() { return <View style={styles.layout}>{this.props.children}</View>; } diff --git a/app/components/Preferences.js b/app/components/Preferences.js index afe802d958..dfe098999a 100644 --- a/app/components/Preferences.js +++ b/app/components/Preferences.js @@ -12,9 +12,7 @@ export type PreferencesProps = { onClose: () => void, }; -export default class Preferences extends Component { - props: PreferencesProps; - +export default class Preferences extends Component<PreferencesProps> { render() { return ( <Layout> diff --git a/app/containers/LoginPage.js b/app/containers/LoginPage.js index dbd49dea03..807c141799 100644 --- a/app/containers/LoginPage.js +++ b/app/containers/LoginPage.js @@ -11,7 +11,9 @@ import { openLink } from '../lib/platform'; import type { ReduxState, ReduxDispatch } from '../redux/store'; import type { SharedRouteProps } from '../routes'; -const mapStateToProps = (state: ReduxState) => state; +const mapStateToProps = (state: ReduxState) => ({ + account: state.account, +}); const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { const { push: pushHistory } = bindActionCreators({ push }, dispatch); const { login, resetLoginError, updateAccountToken } = bindActionCreators( diff --git a/app/containers/SelectLocationPage.js b/app/containers/SelectLocationPage.js index 05b4205dfa..b2ae476912 100644 --- a/app/containers/SelectLocationPage.js +++ b/app/containers/SelectLocationPage.js @@ -10,7 +10,9 @@ import { log } from '../lib/platform'; import type { ReduxState, ReduxDispatch } from '../redux/store'; import type { SharedRouteProps } from '../routes'; -const mapStateToProps = (state: ReduxState) => state; +const mapStateToProps = (state: ReduxState) => ({ + settings: state.settings, +}); const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { const { push: pushHistory } = bindActionCreators({ push }, dispatch); const { backend } = props; diff --git a/app/containers/SettingsPage.js b/app/containers/SettingsPage.js index 24b718485b..2bcef79730 100644 --- a/app/containers/SettingsPage.js +++ b/app/containers/SettingsPage.js @@ -11,12 +11,11 @@ import { openLink, exit } from '../lib/platform'; import type { ReduxState, ReduxDispatch } from '../redux/store'; import type { SharedRouteProps } from '../routes'; -const mapStateToProps = (state: ReduxState) => { - return { - ...state, - version: version, - }; -}; +const mapStateToProps = (state: ReduxState) => ({ + account: state.account, + settings: state.settings, + version: version, +}); const mapDispatchToProps = (dispatch: ReduxDispatch, _props: SharedRouteProps) => { const { push: pushHistory } = bindActionCreators({ push }, dispatch); return { diff --git a/app/containers/SupportPage.js b/app/containers/SupportPage.js index 5d67ddce31..d9ce8ad6ec 100644 --- a/app/containers/SupportPage.js +++ b/app/containers/SupportPage.js @@ -9,7 +9,9 @@ import { collectProblemReport, sendProblemReport } from '../lib/problem-report'; import type { ReduxState, ReduxDispatch } from '../redux/store'; import type { SharedRouteProps } from '../routes'; -const mapStateToProps = (state: ReduxState) => state; +const mapStateToProps = (state: ReduxState) => ({ + account: state.account, +}); const mapDispatchToProps = (dispatch: ReduxDispatch, _props: SharedRouteProps) => { const { push: pushHistory } = bindActionCreators({ push }, dispatch); |
