diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-08-01 14:21:58 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-08-08 15:26:34 +0200 |
| commit | 2f6e76531419c0653212410dc992bf952ee5fbe5 (patch) | |
| tree | 43e2eae17b1ae61da6a05a2e333b88cc6060b2ee /app/components/Settings.js | |
| parent | 21c62239a0ef590e77f3a5a3448f36259755d6d8 (diff) | |
| download | mullvadvpn-2f6e76531419c0653212410dc992bf952ee5fbe5.tar.xz mullvadvpn-2f6e76531419c0653212410dc992bf952ee5fbe5.zip | |
Pull account expiry on demand
Diffstat (limited to 'app/components/Settings.js')
| -rw-r--r-- | app/components/Settings.js | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/app/components/Settings.js b/app/components/Settings.js index 4a8784fe0e..c447940338 100644 --- a/app/components/Settings.js +++ b/app/components/Settings.js @@ -11,13 +11,12 @@ import CustomScrollbars from './CustomScrollbars'; import styles from './SettingsStyles'; import Img from './Img'; -import type { AccountReduxState } from '../redux/account/reducers'; -import type { SettingsReduxState } from '../redux/settings/reducers'; +import type { LoginState } from '../redux/account/reducers'; -export type SettingsProps = { - account: AccountReduxState, - settings: SettingsReduxState, - version: string, +type Props = { + loginState: LoginState, + accountExpiry: ?string, + appVersion: string, onQuit: () => void, onClose: () => void, onViewAccount: () => void, @@ -25,9 +24,14 @@ export type SettingsProps = { onViewPreferences: () => void, onViewAdvancedSettings: () => void, onExternalLink: (type: string) => void, + updateAccountExpiry: () => Promise<void>, }; -export default class Settings extends Component<SettingsProps> { +export default class Settings extends Component<Props> { + componentDidMount() { + this.props.updateAccountExpiry(); + } + render() { return ( <Layout> @@ -60,17 +64,17 @@ export default class Settings extends Component<SettingsProps> { } _renderTopButtons() { - const isLoggedIn = this.props.account.status === 'ok'; + const isLoggedIn = this.props.loginState === 'ok'; if (!isLoggedIn) { return null; } - let isOutOfTime = false, - formattedExpiry = ''; - const expiryIso = this.props.account.expiry; + let isOutOfTime = false; + let formattedExpiry = ''; + const expiryIso = this.props.accountExpiry; if (isLoggedIn && expiryIso) { - const expiry = moment(this.props.account.expiry); + const expiry = moment(expiryIso); isOutOfTime = expiry.isSameOrBefore(moment()); formattedExpiry = (expiry.fromNow(true) + ' left').toUpperCase(); } @@ -86,7 +90,7 @@ export default class Settings extends Component<SettingsProps> { <Cell.SubText testName="settings__account_paid_until_subtext" style={styles.settings__account_paid_until_Label__error}> - OUT OF TIME + {'OUT OF TIME'} </Cell.SubText> <Img height={12} width={7} source="icon-chevron" /> </Cell.CellButton> @@ -136,7 +140,7 @@ export default class Settings extends Component<SettingsProps> { // the version in package.json has to be semver, but we use a YEAR.release-channel // version scheme. in package.json we thus have to write YEAR.release.X-channel and // this function is responsible for removing .X part. - return this.props.version + return this.props.appVersion .replace('.0-', '-') // remove the .0 in 2018.1.0-beta9 .replace(/\.0$/, ''); // remove the .0 in 2018.1.0 } |
