Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Add parameter to customize Wait screen copy. #1152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/action/nav-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class NavAction {
this._reset('Main', 'LoaderSyncing');
}

goWait() {
goWait({ copy = 'Loading network...' }) {
this._store.waitScreenCopy = copy;
this._navigate('Wait');
}

Expand Down
3 changes: 2 additions & 1 deletion src/action/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class NavAction {
this._store.route = 'LoaderSyncing';
}

goWait() {
goWait({ copy = 'Loading network...' }) {
this._store.waitScreenCopy = copy;
this._store.route = 'Wait';
}

Expand Down
4 changes: 2 additions & 2 deletions src/action/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/action/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class Store {
notifications: [],
unseenNtfnCount: 0,
logs: '',
waitScreenCopy: 'Loading network...',

// Persistent data
settings: {
Expand Down
2 changes: 1 addition & 1 deletion src/view/main-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const ResetPasswordSaved = () => <ResetPinSavedView nav={nav} />;

const LoaderSyncing = () => <LoaderSyncingView store={store} />;

const Wait = () => <WaitView />;
const Wait = () => <WaitView store={store} />;

const Home = () => (
<HomeView
Expand Down
2 changes: 1 addition & 1 deletion src/view/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class MainView extends Component {
<NewAddress store={store} invoice={invoice} info={info} />
)}
{route === 'LoaderSyncing' && <LoaderSyncing store={store} />}
{route === 'Wait' && <Wait />}
{route === 'Wait' && <Wait store={store} />}
{route === 'Home' && (
<Home
store={store}
Expand Down
9 changes: 7 additions & 2 deletions src/view/wait-mobile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { StyleSheet, ActivityIndicator } from 'react-native';
import PropTypes from 'prop-types';
import Background from '../component/background';
import MainContent from '../component/main-content';
import Text from '../component/text';
Expand All @@ -19,17 +20,21 @@ const styles = StyleSheet.create({
},
});

const WaitView = () => (
const WaitView = ({ store }) => (
<Background color={color.blackDark}>
<MainContent style={styles.content}>
<ActivityIndicator
size="large"
color={color.lightPurple}
style={styles.spinner}
/>
<Text style={styles.copy}>Loading network...</Text>
<Text style={styles.copy}>{store.waitScreenCopy}</Text>
</MainContent>
</Background>
);

WaitView.propTypes = {
store: PropTypes.object.isRequired,
};

export default WaitView;
9 changes: 7 additions & 2 deletions src/view/wait.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -11,12 +12,16 @@ const styles = StyleSheet.create({
},
});

const WaitView = () => (
const WaitView = ({ store }) => (
<Background color={color.blackDark}>
<MainContent style={styles.content}>
<ContinuousLoadNetworkSpinner msg="Loading network..." />
<ContinuousLoadNetworkSpinner msg={store.waitScreenCopy} />
</MainContent>
</Background>
);

WaitView.propTypes = {
store: PropTypes.object.isRequired,
};

export default WaitView;
4 changes: 2 additions & 2 deletions stories/screen-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ storiesOf('Screens', module)
.add('Loader - Syncing Chain (Mobile)', () => (
<LoaderSyncingMobile store={store} />
))
.add('Wait', () => <Wait />)
.add('Wait (Mobile)', () => <WaitMobile />)
.add('Wait', () => <Wait store={store} />)
.add('Wait (Mobile)', () => <WaitMobile store={store} />)
.add('Home', () => (
<Home
store={store}
Expand Down
9 changes: 8 additions & 1 deletion test/unit/action/nav.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,16 @@ describe('Action Nav Unit Tests', () => {

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()', () => {
Expand Down