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

Commit ac743d1

Browse files
committed
Add waiting flag to notification for spinner
1 parent b2be167 commit ac743d1

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

src/action/info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class InfoAction {
1515
this._store.syncedToChain = response.synced_to_chain;
1616
this._store.blockHeight = response.block_height;
1717
if (!response.synced_to_chain) {
18-
this._notification.display({ msg: 'Syncing to chain ...' });
18+
this._notification.display({ msg: 'Syncing to chain', wait: true });
1919
log.info(`Syncing to chain ... block height: ${response.block_height}`);
2020
clearTimeout(this.t3);
2121
this.t3 = setTimeout(() => this.getInfo(), RETRY_DELAY);

src/action/notification.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ class NotificationAction {
77
this._nav = nav;
88
}
99

10-
display({ type, msg, err, handler, handlerLbl }) {
10+
display({ type, msg, wait, err, handler, handlerLbl }) {
1111
if (err) log.error(msg, err);
1212
this._store.notifications.push({
1313
type: type || (err ? 'error' : 'info'),
1414
message: msg,
15+
waiting: wait,
1516
date: new Date(),
1617
handler: handler || (err ? () => this._nav.goCLI() : null),
1718
handlerLbl: handlerLbl || (err ? 'Show error logs' : null),

src/component/notification.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import PropTypes from 'prop-types';
44
import { SmallPillButton } from './button';
55
import { Text, H4Text } from './text';
66
import Icon from './icon';
7-
import { color, font } from '../component/style';
7+
import { SmallSpinner } from './spinner';
8+
import { color, font } from './style';
89

910
//
1011
// NotificationBar
@@ -47,6 +48,7 @@ export const NotificationBar = ({ notification, display, style }) =>
4748
onPress={notification.handler}
4849
/>
4950
) : null}
51+
{notification.waiting ? <SmallSpinner /> : null}
5052
</View>
5153
) : null;
5254

stories/component/notification.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ import NotificationAction from '../../src/action/notification';
66
import { Store } from '../../src/store';
77

88
const store = new Store();
9+
store.init();
910
export const notify = new NotificationAction(store);
1011

1112
storiesOf('Notification', module)
12-
.add('Notification Bar', () => (
13+
.add('Notification Bar (error)', () => (
1314
<NotificationBar
14-
notification={store.lastNotification}
15+
notification={store.notifications[0]}
16+
display={store.displayNotification}
17+
/>
18+
))
19+
.add('Notification Bar (waiting)', () => (
20+
<NotificationBar
21+
notification={store.notifications[1]}
1522
display={store.displayNotification}
1623
/>
1724
))
@@ -29,3 +36,9 @@ store.notifications.push({
2936
handlerLbl: 'Handle error',
3037
display: true,
3138
});
39+
store.notifications.push({
40+
type: 'info',
41+
message: 'Syncing to chain',
42+
waiting: true,
43+
display: true,
44+
});

0 commit comments

Comments
 (0)