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

Commit 93619eb

Browse files
Add parameter to customize Wait screen copy.
1 parent 18c81b9 commit 93619eb

File tree

13 files changed

+75
-35
lines changed

13 files changed

+75
-35
lines changed

src/action/index-mobile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ export const ipc = sinon.createStubInstance(IpcAction); // STUB DURING DEVELOPME
4949
export const log = new LogAction(store, ipc, false);
5050
export const nav = new NavAction(store, NavigationActions, StackActions);
5151
export const notify = new NotificationAction(store, nav);
52-
export const wallet = new WalletAction(store, grpc, db, nav, notify);
52+
export const payment = new PaymentAction(store, grpc, nav, notify, Clipboard);
53+
export const wallet = new WalletAction(store, grpc, db, nav, notify, payment);
5354
export const info = new InfoAction(store, grpc, nav, notify);
5455
export const transaction = new TransactionAction(store, grpc, nav, notify);
5556
export const channel = new ChannelAction(store, grpc, nav, notify);
5657
export const invoice = new InvoiceAction(store, grpc, nav, notify, Clipboard);
57-
export const payment = new PaymentAction(store, grpc, nav, notify, Clipboard);
5858
export const setting = new SettingAction(store, wallet, db, ipc);
5959
export const auth = new AuthAction(
6060
store,

src/action/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export const log = new LogAction(store, ipc);
3535
export const nav = new NavAction(store);
3636
export const grpc = new GrpcAction(store, ipc);
3737
export const notify = new NotificationAction(store, nav);
38-
export const wallet = new WalletAction(store, grpc, db, nav, notify);
38+
export const payment = new PaymentAction(store, grpc, nav, notify, Clipboard);
39+
export const wallet = new WalletAction(store, grpc, db, nav, notify, payment);
3940
export const info = new InfoAction(store, grpc, nav, notify);
4041
export const transaction = new TransactionAction(store, grpc, nav, notify);
4142
export const channel = new ChannelAction(store, grpc, nav, notify);
4243
export const invoice = new InvoiceAction(store, grpc, nav, notify, Clipboard);
43-
export const payment = new PaymentAction(store, grpc, nav, notify, Clipboard);
4444
export const setting = new SettingAction(store, wallet, db, ipc);
4545
export const autopilot = new AtplAction(store, grpc, db, notify);
4646

src/action/payment.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class PaymentAction {
259259
msg: 'Sending transaction timed out!',
260260
});
261261
}, PAYMENT_TIMEOUT);
262-
this._nav.goWait();
262+
this.initWaitScreen({ copy: 'Sending payment...' });
263263
try {
264264
await this._sendPayment();
265265
this._nav.goPayBitcoinDone();
@@ -295,7 +295,7 @@ class PaymentAction {
295295
this._nav.goPaymentFailed();
296296
}, PAYMENT_TIMEOUT);
297297
try {
298-
this._nav.goWait();
298+
this.initWaitScreen({ copy: 'Sending payment...' });
299299
const invoice = this._store.payment.address;
300300
const stream = this._grpc.sendStreamCommand('sendPayment');
301301
await new Promise((resolve, reject) => {
@@ -319,6 +319,17 @@ class PaymentAction {
319319
clearTimeout(timeout);
320320
}
321321
}
322+
323+
/**
324+
* Initialize the Wait screen with copy appropriate for what the user is
325+
* waiting on.
326+
* @param {string} copy Copy to display.
327+
* @return {undefined}
328+
*/
329+
initWaitScreen({ copy = 'Loading network...' }) {
330+
this._store.waitScreenCopy = copy;
331+
this._nav.goWait();
332+
}
322333
}
323334

324335
export default PaymentAction;

src/action/wallet.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import { when } from 'mobx';
1414
import * as log from './log';
1515

1616
class WalletAction {
17-
constructor(store, grpc, db, nav, notification) {
17+
constructor(store, grpc, db, nav, notification, payment) {
1818
this._store = store;
1919
this._grpc = grpc;
2020
this._db = db;
2121
this._nav = nav;
2222
this._notification = notification;
23+
this._payment = payment;
2324
}
2425

2526
//
@@ -245,7 +246,7 @@ class WalletAction {
245246
this.initResetPassword();
246247
return this._notification.display({ msg: errorMsg });
247248
}
248-
this._nav.goWait();
249+
this._payment.initWaitScreen({ copy: 'Updating password...' });
249250
await this.resetPassword({
250251
currentPassword: password,
251252
newPassword: newPassword,
@@ -394,7 +395,7 @@ class WalletAction {
394395
*/
395396
async unlockWallet({ walletPassword }) {
396397
try {
397-
this._nav.goWait();
398+
this._payment.initWaitScreen({});
398399
await this._grpc.sendUnlockerCommand('UnlockWallet', {
399400
walletPassword: toBuffer(walletPassword),
400401
recoveryWindow: this._store.settings.restoring ? 250 : 0,
@@ -463,7 +464,7 @@ class WalletAction {
463464
if (this._store.walletAddress) {
464465
this._nav.goNewAddress();
465466
} else {
466-
this._nav.goWait();
467+
this._payment.initWaitScreen({});
467468
when(() => this._store.walletAddress, () => this._nav.goNewAddress());
468469
}
469470
}

src/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export class Store {
8585
notifications: [],
8686
unseenNtfnCount: 0,
8787
logs: '',
88+
waitScreenCopy: 'Loading network...',
8889

8990
// Persistent data
9091
settings: {

src/view/main-mobile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const Password = () => <PinView store={store} auth={auth} />;
9595

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

98-
const Wait = () => <WaitView />;
98+
const Wait = () => <WaitView store={store} />;
9999

100100
const Home = () => (
101101
<HomeView

src/view/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class MainView extends Component {
9999
<NewAddress store={store} invoice={invoice} info={info} />
100100
)}
101101
{route === 'LoaderSyncing' && <LoaderSyncing store={store} />}
102-
{route === 'Wait' && <Wait />}
102+
{route === 'Wait' && <Wait store={store} />}
103103
{route === 'Home' && (
104104
<Home
105105
store={store}

src/view/wait-mobile.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { StyleSheet, ActivityIndicator } from 'react-native';
3+
import PropTypes from 'prop-types';
34
import Background from '../component/background';
45
import MainContent from '../component/main-content';
56
import Text from '../component/text';
@@ -19,17 +20,21 @@ const styles = StyleSheet.create({
1920
},
2021
});
2122

22-
const WaitView = () => (
23+
const WaitView = ({ store }) => (
2324
<Background color={color.blackDark}>
2425
<MainContent style={styles.content}>
2526
<ActivityIndicator
2627
size="large"
2728
color={color.lightPurple}
2829
style={styles.spinner}
2930
/>
30-
<Text style={styles.copy}>Loading network...</Text>
31+
<Text style={styles.copy}>{store.waitScreenCopy}</Text>
3132
</MainContent>
3233
</Background>
3334
);
3435

36+
WaitView.propTypes = {
37+
store: PropTypes.object.isRequired,
38+
};
39+
3540
export default WaitView;

src/view/wait.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { StyleSheet } from 'react-native';
3+
import PropTypes from 'prop-types';
34
import Background from '../component/background';
45
import MainContent from '../component/main-content';
56
import { color } from '../component/style';
@@ -11,12 +12,16 @@ const styles = StyleSheet.create({
1112
},
1213
});
1314

14-
const WaitView = () => (
15+
const WaitView = ({ store }) => (
1516
<Background color={color.blackDark}>
1617
<MainContent style={styles.content}>
17-
<ContinuousLoadNetworkSpinner msg="Loading network..." />
18+
<ContinuousLoadNetworkSpinner msg={store.waitScreenCopy} />
1819
</MainContent>
1920
</Background>
2021
);
2122

23+
WaitView.propTypes = {
24+
store: PropTypes.object.isRequired,
25+
};
26+
2227
export default WaitView;

stories/screen-story.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ const ipc = sinon.createStubInstance(IpcAction);
9292
const grpc = sinon.createStubInstance(GrpcAction);
9393
const info = sinon.createStubInstance(InfoAction);
9494
const notify = sinon.createStubInstance(NotificationAction);
95-
const wallet = new WalletAction(store, grpc, db, nav, notify);
95+
const payment = new PaymentAction(store, grpc, nav, notify);
96+
sinon.stub(payment, 'checkType');
97+
sinon.stub(payment, 'payBitcoin');
98+
sinon.stub(payment, 'toggleMax');
99+
sinon.stub(payment, 'payLightning');
100+
sinon.stub(payment, 'initPayBitcoinConfirm');
101+
const wallet = new WalletAction(store, grpc, db, nav, notify, payment);
96102
const setting = new SettingAction(store, wallet, db, ipc);
97103
const autopilot = sinon.createStubInstance(AtplAction);
98104
sinon.stub(wallet, 'update');
@@ -104,12 +110,6 @@ const transaction = new TransactionAction(store, grpc, nav, notify);
104110
sinon.stub(transaction, 'update');
105111
const invoice = new InvoiceAction(store, grpc, nav, notify, Clipboard);
106112
sinon.stub(invoice, 'generateUri');
107-
const payment = new PaymentAction(store, grpc, nav, notify);
108-
sinon.stub(payment, 'checkType');
109-
sinon.stub(payment, 'payBitcoin');
110-
sinon.stub(payment, 'toggleMax');
111-
sinon.stub(payment, 'payLightning');
112-
sinon.stub(payment, 'initPayBitcoinConfirm');
113113
const channel = new ChannelAction(store, grpc, nav, notify);
114114
sinon.stub(channel, 'update');
115115
sinon.stub(channel, 'connectAndOpen');
@@ -178,8 +178,8 @@ storiesOf('Screens', module)
178178
.add('Loader - Syncing Chain (Mobile)', () => (
179179
<LoaderSyncingMobile store={store} />
180180
))
181-
.add('Wait', () => <Wait />)
182-
.add('Wait (Mobile)', () => <WaitMobile />)
181+
.add('Wait', () => <Wait store={store} />)
182+
.add('Wait (Mobile)', () => <WaitMobile store={store} />)
183183
.add('Home', () => (
184184
<Home
185185
store={store}

0 commit comments

Comments
 (0)