diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-07-24 13:32:08 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-07-24 13:32:08 -0300 |
| commit | 7fc6c80ee49d57fc84597d83b0216dd8df6dc127 (patch) | |
| tree | 99ec20452e2b1fb1d40bfb802a695929d1f22ded /app/components | |
| parent | d1632102fbf53032b87fc8f6bcdc7299ee411b15 (diff) | |
| parent | 523473199a6e087d38c1777c2a22a7d8ee027cd9 (diff) | |
| download | mullvadvpn-7fc6c80ee49d57fc84597d83b0216dd8df6dc127.tar.xz mullvadvpn-7fc6c80ee49d57fc84597d83b0216dd8df6dc127.zip | |
Merge branch 'click-to-copy-account'
Diffstat (limited to 'app/components')
| -rw-r--r-- | app/components/Account.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/app/components/Account.js b/app/components/Account.js index 20435d48ba..9b6e1c8dea 100644 --- a/app/components/Account.js +++ b/app/components/Account.js @@ -17,6 +17,7 @@ export type AccountProps = { updateAccountExpiry: () => Promise<void>, onLogout: () => void, onClose: () => void, + onCopyAccountToken: () => void, onBuyMore: () => void, }; @@ -27,12 +28,15 @@ export type AccountState = { export default class Account extends Component<AccountProps, AccountState> { state = { isRefreshingExpiry: false, + showAccountCopiedMessage: false, }; _activationStateToken: ?Types.SubscriptionToken; _isMounted = false; + _copyTimer: ?TimeoutID; + componentDidMount() { this._isMounted = true; this._refreshAccountExpiry(); @@ -47,6 +51,10 @@ export default class Account extends Component<AccountProps, AccountState> { componentWillUnmount() { this._isMounted = false; + if (this._copyTimer) { + clearTimeout(this._copyTimer); + } + const activationStateToken = this._activationStateToken; if (activationStateToken) { activationStateToken.unsubscribe(); @@ -54,6 +62,18 @@ export default class Account extends Component<AccountProps, AccountState> { } } + onAccountTokenClick() { + if (this._copyTimer) { + clearTimeout(this._copyTimer); + } + this._copyTimer = setTimeout( + () => this.setState({ showAccountTokenCopiedMessage: false }), + 3000, + ); + this.setState({ showAccountTokenCopiedMessage: true }); + this.props.onCopyAccountToken(); + } + render() { const expiry = moment(this.props.accountExpiry); const formattedAccountToken = formatAccount(this.props.accountToken || ''); @@ -77,7 +97,13 @@ export default class Account extends Component<AccountProps, AccountState> { <View style={styles.account__main}> <View style={styles.account__row}> <Text style={styles.account__row_label}>Account ID</Text> - <Text style={styles.account__row_value}>{formattedAccountToken}</Text> + <Text + style={styles.account__row_value} + onPress={this.onAccountTokenClick.bind(this)}> + {this.state.showAccountTokenCopiedMessage + ? 'COPIED TO CLIPBOARD!' + : formattedAccountToken} + </Text> </View> <View style={styles.account__row}> |
