aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/wallet
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-30 02:08:48 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-30 02:08:48 +0800
commit36cadaae46eb17261c6dd0ee82cd8cefb3806082 (patch)
tree329e27371ad6a6b67889ed9b92ef8a27a15ef240 /packages/website/ts/components/wallet
parente71862676c298a65fe30abe7d24054871c6a5484 (diff)
downloaddexon-0x-contracts-36cadaae46eb17261c6dd0ee82cd8cefb3806082.tar.gz
dexon-0x-contracts-36cadaae46eb17261c6dd0ee82cd8cefb3806082.tar.zst
dexon-0x-contracts-36cadaae46eb17261c6dd0ee82cd8cefb3806082.zip
Use Image component where relevant and add back tracked token timestamp logic
Diffstat (limited to 'packages/website/ts/components/wallet')
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx18
1 files changed, 16 insertions, 2 deletions
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 5dde0f4e7..e1a2d4ce7 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -156,6 +156,20 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
isHoveringSidebar: false,
};
}
+ public componentDidUpdate(prevProps: WalletProps): void {
+ const currentTrackedTokens = this.props.trackedTokens;
+ const differentTrackedTokens = _.difference(currentTrackedTokens, prevProps.trackedTokens);
+ const firstDifferentTrackedToken = _.head(differentTrackedTokens);
+ // check if there is only one different token, and if that token is a member of the current tracked tokens
+ // this means that the token was added, not removed
+ if (
+ !_.isUndefined(firstDifferentTrackedToken) &&
+ _.size(differentTrackedTokens) === 1 &&
+ _.includes(currentTrackedTokens, firstDifferentTrackedToken)
+ ) {
+ document.getElementById(firstDifferentTrackedToken.address).scrollIntoView();
+ }
+ }
public render(): React.ReactNode {
const isBlockchainLoaded = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError;
return (
@@ -318,7 +332,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const trackedTokensStartingWithEtherToken = trackedTokens.sort(
firstBy((t: Token) => t.symbol !== constants.ETHER_TOKEN_SYMBOL)
.thenBy((t: Token) => t.symbol !== constants.ZRX_TOKEN_SYMBOL)
- .thenBy('address'),
+ .thenBy('trackedTimestamp'),
);
return _.map(trackedTokensStartingWithEtherToken, this._renderTokenRow.bind(this));
}
@@ -375,7 +389,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const style = { ...styles.tokenItem, ...additionalStyle };
const etherToken = this._getEthToken();
return (
- <div key={key} className={`flex flex-column ${className || ''}`}>
+ <div id={key} key={key} className={`flex flex-column ${className || ''}`}>
<StandardIconRow
icon={icon}
main={