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

Commit 8017441

Browse files
authored
Merge pull request #437 from lightninglabs/wait-screen
Wait screen
2 parents c071bd5 + d1bdca2 commit 8017441

File tree

9 files changed

+54
-2
lines changed

9 files changed

+54
-2
lines changed

src/action/nav.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class NavAction {
3131
this._store.route = 'NewAddress';
3232
}
3333

34+
goWait() {
35+
this._store.route = 'Wait';
36+
}
37+
3438
goHome() {
3539
this._store.route = 'Home';
3640
}

src/action/payment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ class PaymentAction {
105105
});
106106
stream.on('error', reject);
107107
stream.write(JSON.stringify({ payment_request: invoice }), 'utf8');
108+
this._nav.goWait();
108109
});
109110
this._nav.goPayLightningDone();
110111
} catch (err) {
112+
this._nav.goPayLightningConfirm();
111113
this._notification.display({ msg: 'Lightning payment failed!', err });
112114
}
113115
await this._transaction.update();

src/action/wallet.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { observe } from 'mobx';
12
import { toBuffer, parseSat, checkHttpStatus, nap } from '../helper';
23
import { MIN_PASSWORD_LENGTH, NOTIFICATION_DELAY } from '../config';
34
import * as log from './log';
@@ -132,7 +133,8 @@ class WalletAction {
132133
wallet_password: toBuffer(walletPassword),
133134
});
134135
this._store.walletUnlocked = true;
135-
this._nav.goHome();
136+
this._nav.goWait();
137+
observe(this._store, 'lndReady', () => this._nav.goHome());
136138
} catch (err) {
137139
this._notification.display({ type: 'error', msg: 'Invalid password' });
138140
}

src/view/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SeedSuccess from './seed-success';
1010
import SetPassword from './set-password';
1111
import Password from './password';
1212
import NewAddress from './new-address';
13+
import Wait from './wait';
1314
import Home from './home';
1415
import Payment from './payment';
1516
import PayLightningConfirm from './pay-lightning-confirm';
@@ -64,6 +65,7 @@ class MainView extends Component {
6465
{route === 'NewAddress' && (
6566
<NewAddress store={store} nav={nav} invoice={invoice} />
6667
)}
68+
{route === 'Wait' && <Wait />}
6769
{route === 'Home' && (
6870
<Home
6971
store={store}

src/view/wait.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { StyleSheet, ActivityIndicator } from 'react-native';
3+
import Background from '../component/background';
4+
import MainContent from '../component/main-content';
5+
import { color } from '../component/style';
6+
7+
const styles = StyleSheet.create({
8+
content: {
9+
justifyContent: 'center',
10+
},
11+
spinner: {
12+
transform: [{ scale: 1.5 }],
13+
},
14+
});
15+
16+
const WaitView = () => (
17+
<Background color={color.blackDark}>
18+
<MainContent style={styles.content}>
19+
<ActivityIndicator
20+
size="large"
21+
color={color.lightPurple}
22+
style={styles.spinner}
23+
/>
24+
</MainContent>
25+
</Background>
26+
);
27+
28+
export default WaitView;

stories/screen.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import SeedVerify from '../src/view/seed-verify';
4343
import SetPassword from '../src/view/set-password';
4444
import Password from '../src/view/password';
4545
import NewAddress from '../src/view/new-address';
46+
import Wait from '../src/view/wait';
4647

4748
const store = new Store();
4849
store.init();
@@ -90,6 +91,7 @@ storiesOf('Screens', module)
9091
.add('New Address', () => (
9192
<NewAddress store={store} nav={nav} invoice={invoice} />
9293
))
94+
.add('Wait', () => <Wait />)
9395
.add('Home', () => (
9496
<Home
9597
store={store}

test/unit/action/nav.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ describe('Action Nav Unit Tests', () => {
6767
});
6868
});
6969

70+
describe('goWait()', () => {
71+
it('should set correct route', () => {
72+
nav.goWait();
73+
expect(store.route, 'to equal', 'Wait');
74+
});
75+
});
76+
7077
describe('goHome()', () => {
7178
it('should set correct route', () => {
7279
nav.goHome();

test/unit/action/payment.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ describe('Action Payments Unit Tests', () => {
203203
JSON.stringify({ payment_request: 'some-invoice' }),
204204
'utf8'
205205
);
206+
expect(nav.goWait, 'was called once');
206207
expect(nav.goPayLightningDone, 'was called once');
207208
expect(notification.display, 'was not called');
208209
expect(transaction.update, 'was called once');
@@ -211,6 +212,7 @@ describe('Action Payments Unit Tests', () => {
211212
it('should display notification on error', async () => {
212213
paymentsOnStub.withArgs('data').yields({ payment_error: 'Boom!' });
213214
await payment.payLightning({ invoice: 'some-payment' });
215+
expect(nav.goPayLightningConfirm, 'was called once');
214216
expect(notification.display, 'was called once');
215217
expect(transaction.update, 'was called once');
216218
});

test/unit/action/wallet.spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ describe('Action Wallet Unit Tests', () => {
238238
expect(grpc.sendUnlockerCommand, 'was called with', 'UnlockWallet', {
239239
wallet_password: Buffer.from('baz', 'utf8'),
240240
});
241+
expect(nav.goWait, 'was called once');
242+
expect(nav.goHome, 'was not called');
243+
store.lndReady = true;
241244
expect(nav.goHome, 'was called once');
242245
});
243246

@@ -247,7 +250,7 @@ describe('Action Wallet Unit Tests', () => {
247250
.rejects(new Error('Boom!'));
248251
await wallet.unlockWallet({ walletPassword: 'baz' });
249252
expect(notification.display, 'was called once');
250-
expect(nav.goHome, 'was not called');
253+
expect(nav.goWait, 'was not called');
251254
});
252255
});
253256

0 commit comments

Comments
 (0)