Skip to content

Commit 925c9a5

Browse files
committed
Fix a bug in are_shallow_equal, add immutable support
1 parent c01c3c7 commit 925c9a5

File tree

7 files changed

+38
-1936
lines changed

7 files changed

+38
-1936
lines changed

app/components/Exchange/Exchange.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,20 @@ class Exchange extends React.Component {
233233
});
234234
}
235235

236-
shouldComponentUpdate(nextProps) {
237-
if (!nextProps.marketReady && !this.props.marketReady) {
236+
shouldComponentUpdate(np, ns) {
237+
if (!np.marketReady && !this.props.marketReady) {
238238
return false;
239239
}
240-
return true;
240+
let propsChanged = false;
241+
for (let key in np) {
242+
if (np.hasOwnProperty(key)) {
243+
propsChanged =
244+
propsChanged ||
245+
!utils.are_equal_shallow(np[key], this.props[key]);
246+
if (propsChanged) break;
247+
}
248+
}
249+
return propsChanged || !utils.are_equal_shallow(ns, this.state);
241250
}
242251

243252
_checkFeeStatus(

app/components/Exchange/ExchangeContainer.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ class ExchangeContainer extends React.Component {
5252
totals: () => {
5353
return MarketsStore.getState().totals;
5454
},
55-
priceData: () => {
56-
return MarketsStore.getState().priceData;
57-
},
58-
volumeData: () => {
59-
return MarketsStore.getState().volumeData;
60-
},
6155
activeMarketHistory: () => {
6256
return MarketsStore.getState().activeMarketHistory;
6357
},

app/components/Exchange/ExchangeHeader.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ export default class ExchangeHeader extends React.Component {
9393
const dayChangeClass =
9494
parseFloat(dayChange) === 0
9595
? ""
96-
: parseFloat(dayChange) < 0 ? "negative" : "positive";
96+
: parseFloat(dayChange) < 0
97+
? "negative"
98+
: "positive";
9799
const volumeBase = marketStats.get("volumeBase");
98100
const volumeQuote = marketStats.get("volumeQuote");
99101
const dayChangeWithSign = dayChange > 0 ? "+" + dayChange : dayChange;
@@ -145,7 +147,9 @@ export default class ExchangeHeader extends React.Component {
145147
let settleAsset =
146148
baseAsset.get("id") == "1.3.0"
147149
? quoteAsset
148-
: quoteAsset.get("id") == "1.3.0" ? baseAsset : null;
150+
: quoteAsset.get("id") == "1.3.0"
151+
? baseAsset
152+
: null;
149153

150154
if (settleAsset && feedPrice) {
151155
let offset_percent = settleAsset
@@ -441,10 +445,14 @@ export default class ExchangeHeader extends React.Component {
441445
}}
442446
>
443447
<option value="market_depth">
444-
<Translate content="exchange.order_depth" />
448+
{counterpart.translate(
449+
"exchange.order_depth"
450+
)}
445451
</option>
446452
<option value="price_chart">
447-
<Translate content="exchange.price_history" />
453+
{counterpart.translate(
454+
"exchange.price_history"
455+
)}
448456
</option>
449457
</select>
450458
</li>

0 commit comments

Comments
 (0)