aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-07 05:05:13 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-07 05:05:13 +0800
commitd5c378b09aff6e56585f9d05779d72c4e7919d5b (patch)
tree7e0fb017321c486273a67ae9a000ae8ed735d4bb /ui/app
parent8dcba9a606f6d3593a5eedbc96452b9828179262 (diff)
downloadtangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.tar
tangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.tar.gz
tangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.tar.bz2
tangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.tar.lz
tangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.tar.xz
tangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.tar.zst
tangerine-wallet-browser-d5c378b09aff6e56585f9d05779d72c4e7919d5b.zip
Cache identicons
Fixes #197 Also as a side effect, by creating this `iconFactory.cache` object, we have a convenient place for specifying stock icons for known contracts! We can just hard-code image addresses in the `ui/lib/icon-factory.js` cache instantiation, and those values will be injected into the identicon image tag `src` attributes.
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/components/identicon.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js
index ef625cc62..fd61b3125 100644
--- a/ui/app/components/identicon.js
+++ b/ui/app/components/identicon.js
@@ -1,8 +1,10 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const jazzicon = require('jazzicon')
const findDOMNode = require('react-dom').findDOMNode
+const jazzicon = require('jazzicon')
+const iconFactoryGen = require('../../lib/icon-factory')
+const iconFactory = iconFactoryGen(jazzicon)
module.exports = IdenticonComponent
@@ -35,21 +37,14 @@ IdenticonComponent.prototype.componentDidMount = function(){
var address = state.address
if (!address) return
- var numericRepresentation = jsNumberForAddress(address)
var container = findDOMNode(this)
- // jazzicon with hack to fix inline svg error
+
var diameter = state.diameter || this.defaultDiameter
- var identicon = jazzicon(diameter, numericRepresentation)
- var identiconSrc = identicon.innerHTML
- var dataUri = 'data:image/svg+xml;charset=utf-8,'+encodeURIComponent(identiconSrc)
+ var dataUri = iconFactory.iconForAddress(address, diameter)
+
var img = document.createElement('img')
img.src = dataUri
container.appendChild(img)
}
-function jsNumberForAddress(address) {
- var addr = address.slice(2, 10)
- var seed = parseInt(addr, 16)
- return seed
-}