Skip to content

Commit 0397687

Browse files
committed
Adds transactions preloader
1 parent f503c08 commit 0397687

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

source/renderer/app/components/wallet/transactions/WalletTransactionsList.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ type Props = {
7272
onCopyAssetItem: Function,
7373
};
7474

75+
type State = {
76+
isPreloading: boolean,
77+
};
78+
7579
const DATE_FORMAT = 'YYYY-MM-DD';
7680

7781
@observer
78-
export default class WalletTransactionsList extends Component<Props> {
82+
export default class WalletTransactionsList extends Component<Props, State> {
7983
static contextTypes = {
8084
intl: intlShape.isRequired,
8185
};
@@ -87,6 +91,26 @@ export default class WalletTransactionsList extends Component<Props> {
8791
onOpenExternalLink: () => {},
8892
};
8993

94+
state = {
95+
isPreloading: true,
96+
};
97+
98+
// We need to track the mounted state in order to avoid calling
99+
// setState promise handling code after the component was already unmounted:
100+
// Read more: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
101+
_isMounted = false;
102+
103+
componentDidMount() {
104+
this._isMounted = true;
105+
setTimeout(() => {
106+
if (this._isMounted) this.setState({ isPreloading: false });
107+
}, 0);
108+
}
109+
110+
componentWillUnmount() {
111+
this._isMounted = false;
112+
}
113+
90114
expandedTransactionIds: Map<string, WalletTransaction> = new Map();
91115
transactionsShowingMetadata: Map<string, WalletTransaction> = new Map();
92116
virtualList: ?VirtualTransactionList;
@@ -269,6 +293,8 @@ export default class WalletTransactionsList extends Component<Props> {
269293
};
270294

271295
render() {
296+
const { intl } = this.context;
297+
const { isPreloading } = this.state;
272298
const {
273299
hasMoreToLoad,
274300
isLoadingTransactions,
@@ -278,8 +304,6 @@ export default class WalletTransactionsList extends Component<Props> {
278304
transactions,
279305
walletId,
280306
} = this.props;
281-
282-
const { intl } = this.context;
283307
const transactionsGroups = this.groupTransactionsByDay(transactions);
284308

285309
const loadingSpinner =
@@ -335,6 +359,13 @@ export default class WalletTransactionsList extends Component<Props> {
335359
/>
336360
);
337361

362+
if (isPreloading)
363+
return (
364+
<div className={styles.preloadingBlockWrapper}>
365+
<LoadingSpinner big />
366+
</div>
367+
);
368+
338369
return (
339370
<div className={styles.component}>
340371
{syncingTransactionsSpinner}

source/renderer/app/components/wallet/transactions/WalletTransactionsList.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,17 @@
6969
display: block !important;
7070
margin: 30px auto 20px;
7171
}
72+
73+
.preloadingBlockWrapper {
74+
align-items: center;
75+
display: flex;
76+
flex: 1;
77+
justify-content: center;
78+
min-height: 44px;
79+
80+
:global {
81+
.LoadingSpinner_component {
82+
margin: 0;
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)