From 21569980d698b6dab47b641acf7dc1946bc80695 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Mon, 10 Jun 2019 18:10:40 -0700 Subject: [PATCH] Add parameter to customize Wait screen copy. --- src/action/nav-mobile.js | 3 ++- src/action/nav.js | 3 ++- src/action/payment.js | 4 ++-- src/action/wallet.js | 6 +++--- src/store.js | 1 + src/view/main-mobile.js | 2 +- src/view/main.js | 2 +- src/view/wait-mobile.js | 9 +++++++-- src/view/wait.js | 9 +++++++-- stories/screen-story.js | 4 ++-- test/unit/action/nav.spec.js | 9 ++++++++- 11 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/action/nav-mobile.js b/src/action/nav-mobile.js index 2aac031b1..8c63030e2 100644 --- a/src/action/nav-mobile.js +++ b/src/action/nav-mobile.js @@ -96,7 +96,8 @@ class NavAction { this._reset('Main', 'LoaderSyncing'); } - goWait() { + goWait({ copy = 'Loading network...' }) { + this._store.waitScreenCopy = copy; this._navigate('Wait'); } diff --git a/src/action/nav.js b/src/action/nav.js index 3fb5cc945..3adbd51f6 100644 --- a/src/action/nav.js +++ b/src/action/nav.js @@ -69,7 +69,8 @@ class NavAction { this._store.route = 'LoaderSyncing'; } - goWait() { + goWait({ copy = 'Loading network...' }) { + this._store.waitScreenCopy = copy; this._store.route = 'Wait'; } diff --git a/src/action/payment.js b/src/action/payment.js index b85a2df7e..4c77b7bb3 100644 --- a/src/action/payment.js +++ b/src/action/payment.js @@ -265,7 +265,7 @@ class PaymentAction { msg: 'Sending transaction timed out!', }); }, PAYMENT_TIMEOUT); - this._nav.goWait(); + this._nav.goWait({ copy: 'Sending payment...' }); try { await this._sendPayment(); this._nav.goPayBitcoinDone(); @@ -302,7 +302,7 @@ class PaymentAction { this._nav.goPaymentFailed(); }, PAYMENT_TIMEOUT); try { - this._nav.goWait(); + this._nav.goWait({ copy: 'Sending payment...' }); const invoice = this._store.payment.address; const stream = this._grpc.sendStreamCommand('sendPayment'); await new Promise((resolve, reject) => { diff --git a/src/action/wallet.js b/src/action/wallet.js index 0530e6ccd..997923dfd 100644 --- a/src/action/wallet.js +++ b/src/action/wallet.js @@ -247,7 +247,7 @@ class WalletAction { this.initResetPassword(); return this._notification.display({ msg: errorMsg }); } - this._nav.goWait(); + this._nav.goWait({ copy: 'Updating password...' }); await this.resetPassword({ currentPassword: password, newPassword: newPassword, @@ -396,7 +396,7 @@ class WalletAction { */ async unlockWallet({ walletPassword }) { try { - this._nav.goWait(); + this._nav.goWait({}); await this._grpc.sendUnlockerCommand('UnlockWallet', { walletPassword: toBuffer(walletPassword), recoveryWindow: this._store.settings.restoring ? 250 : 0, @@ -465,7 +465,7 @@ class WalletAction { if (this._store.walletAddress) { this._nav.goNewAddress(); } else { - this._nav.goWait(); + this._nav.goWait({}); when(() => this._store.walletAddress, () => this._nav.goNewAddress()); } } diff --git a/src/store.js b/src/store.js index 85e5880a0..86313c7b0 100644 --- a/src/store.js +++ b/src/store.js @@ -89,6 +89,7 @@ export class Store { notifications: [], unseenNtfnCount: 0, logs: '', + waitScreenCopy: 'Loading network...', // Persistent data settings: { diff --git a/src/view/main-mobile.js b/src/view/main-mobile.js index 21401448f..286653338 100644 --- a/src/view/main-mobile.js +++ b/src/view/main-mobile.js @@ -111,7 +111,7 @@ const ResetPasswordSaved = () => ; const LoaderSyncing = () => ; -const Wait = () => ; +const Wait = () => ; const Home = () => ( )} {route === 'LoaderSyncing' && } - {route === 'Wait' && } + {route === 'Wait' && } {route === 'Home' && ( ( +const WaitView = ({ store }) => ( ( color={color.lightPurple} style={styles.spinner} /> - Loading network... + {store.waitScreenCopy} ); +WaitView.propTypes = { + store: PropTypes.object.isRequired, +}; + export default WaitView; diff --git a/src/view/wait.js b/src/view/wait.js index 996fd25d1..1d22000e7 100644 --- a/src/view/wait.js +++ b/src/view/wait.js @@ -1,5 +1,6 @@ import React from 'react'; import { StyleSheet } from 'react-native'; +import PropTypes from 'prop-types'; import Background from '../component/background'; import MainContent from '../component/main-content'; import { color } from '../component/style'; @@ -11,12 +12,16 @@ const styles = StyleSheet.create({ }, }); -const WaitView = () => ( +const WaitView = ({ store }) => ( - + ); +WaitView.propTypes = { + store: PropTypes.object.isRequired, +}; + export default WaitView; diff --git a/stories/screen-story.js b/stories/screen-story.js index fab8eca56..904f782e3 100644 --- a/stories/screen-story.js +++ b/stories/screen-story.js @@ -192,8 +192,8 @@ storiesOf('Screens', module) .add('Loader - Syncing Chain (Mobile)', () => ( )) - .add('Wait', () => ) - .add('Wait (Mobile)', () => ) + .add('Wait', () => ) + .add('Wait (Mobile)', () => ) .add('Home', () => ( { describe('goWait()', () => { it('should set correct route', () => { - nav.goWait(); + nav.goWait({}); expect(store.route, 'to equal', 'Wait'); }); + + it('should set correct copy', () => { + const testCopy = 'foobar'; + nav.goWait({ copy: testCopy }); + expect(store.route, 'to equal', 'Wait'); + expect(store.waitScreenCopy, 'to equal', testCopy); + }); }); describe('goHome()', () => {