aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-01-18 04:59:25 +0800
committerChi Kei Chan <chikeichan@gmail.com>2018-01-18 05:52:59 +0800
commitfdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672 (patch)
tree6c1f51c962230d03994c45dc6041f77dae9406de
parent40e58d31326cc4e759991d15e7e84140e483a791 (diff)
downloadtangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.tar
tangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.tar.gz
tangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.tar.bz2
tangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.tar.lz
tangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.tar.xz
tangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.tar.zst
tangerine-wallet-browser-fdaf6eacb2dc6cbd6941dd7debdd5cd89fca4672.zip
Show now tokens by default and improve search on add token screen.
-rw-r--r--ui/app/add-token.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index bb34f5d00..e3fe93362 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -3,6 +3,7 @@ const Component = require('react').Component
const classnames = require('classnames')
const h = require('react-hyperscript')
const connect = require('react-redux').connect
+const R = require('ramda');
const Fuse = require('fuse.js')
const contractMap = require('eth-contract-metadata')
const TokenBalance = require('./components/token-balance')
@@ -17,12 +18,14 @@ const fuse = new Fuse(contractList, {
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
- keys: ['address', 'name', 'symbol'],
+ keys: [
+ { name: 'name', weight: 0.5 },
+ { name: 'symbol', weight: 0.5 },
+ ],
})
const actions = require('./actions')
const ethUtil = require('ethereumjs-util')
const { tokenInfoGetter } = require('./token-util')
-const R = require('ramda')
const emptyAddr = '0x0000000000000000000000000000000000000000'
@@ -217,9 +220,11 @@ AddTokenScreen.prototype.renderCustomForm = function () {
AddTokenScreen.prototype.renderTokenList = function () {
const { searchQuery = '', selectedTokens } = this.state
- const results = searchQuery
- ? fuse.search(searchQuery) || []
- : contractList
+ const fuseSearchResult = fuse.search(searchQuery)
+ const addressSearchResult = contractList.filter(token => {
+ return token.address.toLowerCase() === searchQuery.toLowerCase()
+ })
+ const results = [...addressSearchResult, ...fuseSearchResult]
return Array(6).fill(undefined)
.map((_, i) => {