Skip to content

Commit a95f256

Browse files
lukechildssindresorhus
authored andcommitted
Only show open orders on exchange view (#484)
1 parent 2718a53 commit a95f256

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

app/locales/en-US/exchange.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"quit": "Quit",
3030
"swaps": {
3131
"all": "All",
32-
"title": "Recent Swaps",
32+
"title": "Open Orders",
3333
"viewAllSwaps": "View all swaps"
3434
}
3535
}

app/renderer/containers/Exchange.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExchangeContainer extends SuperContainer {
1515
return {
1616
baseCurrency: 'CHIPS',
1717
quoteCurrency: 'KMD',
18-
activeSwapsView: 'All',
18+
activeSwapsView: 'OpenOrders',
1919
swapHistory: [],
2020
orderBook: {
2121
bids: [],

app/renderer/views/Exchange/Swaps.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const t = translate('exchange');
1010

1111
const swapLimit = 50;
1212

13+
const getOpenOrders = () => exchangeContainer.state.swapHistory.filter(swap => !['completed', 'failed'].includes(swap.status));
14+
1315
const TabButton = props => (
1416
<span
1517
className={
@@ -32,16 +34,20 @@ const TabView = ({component}) => (
3234
<View component={component} activeView={exchangeContainer.state.activeSwapsView}/>
3335
);
3436

35-
const All = () => (
36-
<SwapList swaps={exchangeContainer.state.swapHistory} limit={swapLimit} showCancel/>
37-
);
37+
const OpenOrders = () => {
38+
const openOrders = getOpenOrders();
39+
40+
return (
41+
<SwapList swaps={openOrders} limit={swapLimit} showCancel/>
42+
);
43+
};
3844

39-
const Split = () => {
45+
const CurrentPairOpenOrders = () => {
4046
const {state} = exchangeContainer;
4147

42-
const filteredData = state.swapHistory.filter(x =>
43-
x.baseCurrency === state.baseCurrency &&
44-
x.quoteCurrency === state.quoteCurrency
48+
const filteredData = getOpenOrders().filter(swap =>
49+
swap.baseCurrency === state.baseCurrency &&
50+
swap.quoteCurrency === state.quoteCurrency
4551
);
4652

4753
return (
@@ -59,17 +65,17 @@ const Swaps = () => {
5965
<nav>
6066
<TabButton
6167
title={t('swaps.all')}
62-
component={All}
68+
component={OpenOrders}
6369
/>
6470
<TabButton
6571
title={`${state.baseCurrency}/${state.quoteCurrency}`}
66-
component={Split}
72+
component={CurrentPairOpenOrders}
6773
/>
6874
</nav>
6975
</header>
7076
<main>
71-
<TabView component={All}/>
72-
<TabView component={Split}/>
77+
<TabView component={OpenOrders}/>
78+
<TabView component={CurrentPairOpenOrders}/>
7379
</main>
7480
</div>
7581
);

0 commit comments

Comments
 (0)