diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-02-11 09:11:27 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-02-11 09:11:27 +0100 |
| commit | a15f9a329564d0b6638c0b9923b3af7326f236e1 (patch) | |
| tree | 2bf5396b4cd93baa1b551e74b60d8f9a4a5ce493 /gui/src/renderer | |
| parent | c9b3e7f007b0dd340ea810bca05abef36a325b7f (diff) | |
| parent | 83a1b073c6616330fa48468deaa13ade13ed711c (diff) | |
| download | mullvadvpn-a15f9a329564d0b6638c0b9923b3af7326f236e1.tar.xz mullvadvpn-a15f9a329564d0b6638c0b9923b3af7326f236e1.zip | |
Merge branch 'short-time-left-notification'
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/components/Account.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/Connect.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/NotificationArea.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/Settings.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/containers/ConnectPage.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/containers/NotificationAreaContainer.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/lib/account-expiry.ts | 35 |
7 files changed, 6 insertions, 41 deletions
diff --git a/gui/src/renderer/components/Account.tsx b/gui/src/renderer/components/Account.tsx index 1390f78370..5b5a393f62 100644 --- a/gui/src/renderer/components/Account.tsx +++ b/gui/src/renderer/components/Account.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Component, Text, View } from 'reactxp'; +import AccountExpiry from '../../shared/account-expiry'; import { messages } from '../../shared/gettext'; -import AccountExpiry from '../lib/account-expiry'; import styles from './AccountStyles'; import * as AppButton from './AppButton'; import ClipboardLabel from './ClipboardLabel'; diff --git a/gui/src/renderer/components/Connect.tsx b/gui/src/renderer/components/Connect.tsx index 4cb63c6a5b..2308a91dff 100644 --- a/gui/src/renderer/components/Connect.tsx +++ b/gui/src/renderer/components/Connect.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { Component, Styles, View } from 'reactxp'; import { links } from '../../config.json'; +import AccountExpiry from '../../shared/account-expiry'; import NotificationAreaContainer from '../containers/NotificationAreaContainer'; -import AccountExpiry from '../lib/account-expiry'; import { AuthFailureKind, parseAuthFailure } from '../lib/auth-failure'; import { IConnectionReduxState } from '../redux/connection/reducers'; import { IVersionReduxState } from '../redux/version/reducers'; diff --git a/gui/src/renderer/components/NotificationArea.tsx b/gui/src/renderer/components/NotificationArea.tsx index c459695a30..243b406518 100644 --- a/gui/src/renderer/components/NotificationArea.tsx +++ b/gui/src/renderer/components/NotificationArea.tsx @@ -13,8 +13,8 @@ import { NotificationTitle, } from './NotificationBanner'; +import AccountExpiry from '../../shared/account-expiry'; import { ErrorStateCause, TunnelParameterError, TunnelState } from '../../shared/daemon-rpc-types'; -import AccountExpiry from '../lib/account-expiry'; import { parseAuthFailure } from '../lib/auth-failure'; import { IVersionReduxState } from '../redux/version/reducers'; diff --git a/gui/src/renderer/components/Settings.tsx b/gui/src/renderer/components/Settings.tsx index dc7f875529..ee5cc8c340 100644 --- a/gui/src/renderer/components/Settings.tsx +++ b/gui/src/renderer/components/Settings.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { Component, Text, View } from 'reactxp'; import { colors, links } from '../../config.json'; +import AccountExpiry from '../../shared/account-expiry'; import { messages } from '../../shared/gettext'; -import AccountExpiry from '../lib/account-expiry'; import * as AppButton from './AppButton'; import * as Cell from './Cell'; import { Container, Layout } from './Layout'; diff --git a/gui/src/renderer/containers/ConnectPage.tsx b/gui/src/renderer/containers/ConnectPage.tsx index e4c37f19cc..de691b0db9 100644 --- a/gui/src/renderer/containers/ConnectPage.tsx +++ b/gui/src/renderer/containers/ConnectPage.tsx @@ -3,10 +3,10 @@ import log from 'electron-log'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { sprintf } from 'sprintf-js'; +import AccountExpiry from '../../shared/account-expiry'; import { messages } from '../../shared/gettext'; import Connect from '../components/Connect'; import withAppContext, { IAppContext } from '../context'; -import AccountExpiry from '../lib/account-expiry'; import { IRelayLocationRedux, RelaySettingsRedux } from '../redux/settings/reducers'; import { IReduxState, ReduxDispatch } from '../redux/store'; diff --git a/gui/src/renderer/containers/NotificationAreaContainer.tsx b/gui/src/renderer/containers/NotificationAreaContainer.tsx index 814b055d97..f282c48fab 100644 --- a/gui/src/renderer/containers/NotificationAreaContainer.tsx +++ b/gui/src/renderer/containers/NotificationAreaContainer.tsx @@ -2,9 +2,9 @@ import { connect } from 'react-redux'; import { shell } from 'electron'; import { links } from '../../config.json'; +import AccountExpiry from '../../shared/account-expiry'; import NotificationArea from '../components/NotificationArea'; import withAppContext, { IAppContext } from '../context'; -import AccountExpiry from '../lib/account-expiry'; import { IReduxState, ReduxDispatch } from '../redux/store'; const mapStateToProps = (state: IReduxState, _props: IAppContext) => ({ diff --git a/gui/src/renderer/lib/account-expiry.ts b/gui/src/renderer/lib/account-expiry.ts deleted file mode 100644 index 5393238dcd..0000000000 --- a/gui/src/renderer/lib/account-expiry.ts +++ /dev/null @@ -1,35 +0,0 @@ -import moment from 'moment'; -import { sprintf } from 'sprintf-js'; -import { messages } from '../../shared/gettext'; - -export default class AccountExpiry { - private expiry: moment.Moment; - - constructor(isoString: string, locale: string) { - this.expiry = moment(isoString).locale(locale); - } - - public hasExpired(): boolean { - return this.willHaveExpiredAt(new Date()); - } - - public willHaveExpiredAt(date: Date): boolean { - return this.expiry.isSameOrBefore(date); - } - - public formattedDate(): string { - return this.expiry.format('L LTS'); - } - - public remainingTime(): string { - const duration = this.expiry.fromNow(true); - - return sprintf( - // TRANSLATORS: The remaining time left on the account displayed across the app. - // TRANSLATORS: Available placeholders: - // TRANSLATORS: %(duration)s - a localized remaining time (in minutes, hours, or days) until the account expiry - messages.pgettext('account-expiry', '%(duration)s left'), - { duration }, - ); - } -} |
