aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrankie <frankie.pangilinan@consensys.net>2016-06-09 05:12:25 +0800
committerFrankie <frankie.pangilinan@consensys.net>2016-06-09 05:12:25 +0800
commit03e9ff6e42fe230a1f7a0e6185eca57248c7a2ed (patch)
treee47867a4f8a8ad4d6ed3ae200cc08c7f0dc1f88c
parente9407777cc6f44a87a4c34e07562f278d66a48c4 (diff)
parent1836b83a530a001b83bffebbcf3483220fa02a21 (diff)
downloadtangerine-wallet-browser-03e9ff6e42fe230a1f7a0e6185eca57248c7a2ed.tar.gz
tangerine-wallet-browser-03e9ff6e42fe230a1f7a0e6185eca57248c7a2ed.tar.zst
tangerine-wallet-browser-03e9ff6e42fe230a1f7a0e6185eca57248c7a2ed.zip
Mend CHANGE.log
-rw-r--r--CHANGELOG.md5
-rw-r--r--app/images/ethereum-network.jpgbin10807 -> 0 bytes
-rw-r--r--app/images/morden-test-network.jpgbin10517 -> 0 bytes
-rw-r--r--app/images/no-connection.jpgbin6946 -> 0 bytes
-rw-r--r--app/images/unknown-private-network.jpgbin3962 -> 0 bytes
-rw-r--r--app/manifest.json2
-rw-r--r--test/unit/lib/icon-factory-test.js31
-rw-r--r--ui/app/components/identicon.js17
-rw-r--r--ui/lib/icon-factory.js52
9 files changed, 95 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ca97eea5..fa7149e9d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,12 @@
# Changelog
## Current Master
+
- Style up the info page
+- Cache identicon images to optimize for long lists of transactions.
+
+## 2.3.0 2016-06-06
+
- Show network status in title bar
- Added seed word recovery to config screen.
- Clicking network status indicator now reveals a provider menu.
diff --git a/app/images/ethereum-network.jpg b/app/images/ethereum-network.jpg
deleted file mode 100644
index 61cb000ed..000000000
--- a/app/images/ethereum-network.jpg
+++ /dev/null
Binary files differ
diff --git a/app/images/morden-test-network.jpg b/app/images/morden-test-network.jpg
deleted file mode 100644
index 458708c78..000000000
--- a/app/images/morden-test-network.jpg
+++ /dev/null
Binary files differ
diff --git a/app/images/no-connection.jpg b/app/images/no-connection.jpg
deleted file mode 100644
index a5d21242b..000000000
--- a/app/images/no-connection.jpg
+++ /dev/null
Binary files differ
diff --git a/app/images/unknown-private-network.jpg b/app/images/unknown-private-network.jpg
deleted file mode 100644
index b8a5a9bbf..000000000
--- a/app/images/unknown-private-network.jpg
+++ /dev/null
Binary files differ
diff --git a/app/manifest.json b/app/manifest.json
index ce157bdf3..8cb797e03 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "Metamask",
- "version": "2.2.0",
+ "version": "2.3.0",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
diff --git a/test/unit/lib/icon-factory-test.js b/test/unit/lib/icon-factory-test.js
new file mode 100644
index 000000000..2f24d408c
--- /dev/null
+++ b/test/unit/lib/icon-factory-test.js
@@ -0,0 +1,31 @@
+const assert = require('assert')
+const sinon = require('sinon')
+
+const path = require('path')
+const IconFactoryGen = require(path.join(__dirname, '..', '..', '..', 'ui', 'lib', 'icon-factory.js'))
+
+describe('icon-factory', function() {
+ let iconFactory, address, diameter
+
+ beforeEach(function() {
+ iconFactory = IconFactoryGen((d,n) => 'stubicon')
+ address = '0x012345671234567890'
+ diameter = 50
+ })
+
+ it('should return a data-uri string for any address and diameter', function() {
+ const output = iconFactory.iconForAddress(address, diameter)
+ assert.ok(output.indexOf('data:image/svg') === 0)
+ assert.equal(output, iconFactory.cache[address][diameter])
+ })
+
+ it('should default to cache first', function() {
+ const testOutput = 'foo'
+ const mockSizeCache = {}
+ mockSizeCache[diameter] = testOutput
+ iconFactory.cache[address] = mockSizeCache
+
+ const output = iconFactory.iconForAddress(address, diameter)
+ assert.equal(output, testOutput)
+ })
+})
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
-}
diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js
new file mode 100644
index 000000000..1b1df9490
--- /dev/null
+++ b/ui/lib/icon-factory.js
@@ -0,0 +1,52 @@
+var iconFactory
+
+module.exports = function(jazzicon) {
+ if (!iconFactory) {
+ iconFactory = new IconFactory(jazzicon)
+ }
+ return iconFactory
+}
+
+function IconFactory(jazzicon) {
+ this.jazzicon = jazzicon
+ this.cache = {}
+}
+
+IconFactory.prototype.iconForAddress = function(address, diameter) {
+ if (this.isCached(address, diameter)) {
+ return this.cache[address][diameter]
+ }
+
+ const dataUri = this.generateNewUri(address, diameter)
+ this.cacheIcon(address, diameter, dataUri)
+ return dataUri
+}
+
+IconFactory.prototype.generateNewUri = function(address, diameter) {
+ var numericRepresentation = jsNumberForAddress(address)
+ var identicon = this.jazzicon(diameter, numericRepresentation)
+ var identiconSrc = identicon.innerHTML
+ var dataUri = 'data:image/svg+xml;charset=utf-8,'+encodeURIComponent(identiconSrc)
+ return dataUri
+}
+
+IconFactory.prototype.cacheIcon = function(address, diameter, icon) {
+ if (!(address in this.cache)) {
+ var sizeCache = {}
+ sizeCache[diameter] = icon
+ return this.cache[address] = sizeCache
+
+ } else {
+ return this.cache[address][diameter] = icon
+ }
+}
+
+IconFactory.prototype.isCached = function(address, diameter) {
+ return address in this.cache && diameter in this.cache[address]
+}
+
+function jsNumberForAddress(address) {
+ var addr = address.slice(2, 10)
+ var seed = parseInt(addr, 16)
+ return seed
+}