aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Clark <jason@longview.tech>2017-11-25 01:35:17 +0800
committerJason Clark <jason@longview.tech>2017-11-25 01:35:17 +0800
commitfc46a16a329df296cb565e3a0b04f268d2aeceb5 (patch)
treeba5d45f1ad2f5b3a5f0fb4deb82cbf889b737612
parent90fc4812bc75857581e56eb6d63484dbc5c48cb1 (diff)
downloadtangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.tar
tangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.tar.gz
tangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.tar.bz2
tangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.tar.lz
tangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.tar.xz
tangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.tar.zst
tangerine-wallet-browser-fc46a16a329df296cb565e3a0b04f268d2aeceb5.zip
toggle wired up to preferences property store
-rw-r--r--app/scripts/controllers/preferences.js4
-rw-r--r--app/scripts/metamask-controller.js10
-rw-r--r--package.json9
-rw-r--r--ui/app/actions.js23
-rw-r--r--ui/app/reducers/metamask.js8
-rw-r--r--ui/app/settings.js19
6 files changed, 47 insertions, 26 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index c0454f77b..7ccb0e730 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -14,8 +14,8 @@ class PreferencesController {
}
// PUBLIC METHODS
- toggleUseBlockie () {
- this.store.updateState({ useBlockie: !this.useBlockie() })
+ setUseBlockie (val) {
+ this.store.updateState({ useBlockie: val })
}
getUseBlockie () {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index bd71da8e0..3a935d895 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -315,6 +315,7 @@ module.exports = class MetamaskController extends EventEmitter {
// etc
getState: (cb) => cb(null, this.getState()),
setCurrentCurrency: this.setCurrentCurrency.bind(this),
+ setUseBlockie: this.setUseBlockie.bind(this),
markAccountsFound: this.markAccountsFound.bind(this),
// coinbase
@@ -774,4 +775,13 @@ module.exports = class MetamaskController extends EventEmitter {
return rpcTarget
}
+ setUseBlockie(val, cb) {
+ try {
+ this.preferencesController.setUseBlockie(val)
+ cb(null)
+ } catch (err) {
+ cb(err)
+ }
+ }
+
}
diff --git a/package.json b/package.json
index c0e21ffa7..643e7c9a3 100644
--- a/package.json
+++ b/package.json
@@ -52,11 +52,11 @@
]
},
"dependencies": {
- "abi-decoder": "^1.0.8",
+ "abi-decoder": "^1.0.9",
"async": "^2.5.0",
"await-semaphore": "^0.1.1",
"babel-runtime": "^6.23.0",
- "bignumber.js": "^4.0.4",
+ "bignumber.js": "^4.1.0",
"bip39": "^2.2.0",
"blockies": "0.0.2",
"bluebird": "^3.5.0",
@@ -101,7 +101,7 @@
"extensionizer": "^1.0.0",
"fast-json-patch": "^2.0.4",
"fast-levenshtein": "^2.0.6",
- "fuse.js": "^3.1.0",
+ "fuse.js": "^3.2.0",
"gulp-autoprefixer": "^4.0.0",
"gulp-eslint": "^4.0.0",
"gulp-sass": "^3.1.0",
@@ -147,9 +147,10 @@
"react-select": "^1.0.0",
"react-simple-file-input": "^2.0.0",
"react-toggle": "^4.0.2",
+ "react-toggle-button": "^2.2.0",
"react-toggle-switch": "^3.0.3",
"react-tooltip-component": "^0.3.0",
- "react-transition-group": "^2.2.0",
+ "react-transition-group": "^2.2.1",
"react-trigger-change": "^1.0.2",
"reactify": "^1.1.1",
"readable-stream": "^2.3.3",
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 957e42223..2819742e5 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -235,8 +235,8 @@ var actions = {
useEtherscanProvider,
- TOGGLE_USE_BLOCKIE: 'TOGGLE_USE_BLOCKIE',
- toggleUseBlockie,
+ SET_USE_BLOCKIE: 'SET_USE_BLOCKIE',
+ setUseBlockie,
}
module.exports = actions
@@ -1554,8 +1554,19 @@ function toggleAccountMenu () {
}
}
-function toggleUseBlockie () {
- return {
- type: actions.TOGGLE_USE_BLOCKIE,
+function setUseBlockie (val) {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ log.debug(`background.setUseBlockie`)
+ background.setUseBlockie(val, (err) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ })
+ dispatch({
+ type: actions.SET_USE_BLOCKIE,
+ value: val
+ })
}
-}
+} \ No newline at end of file
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index ee496dc6f..1b747e188 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -315,10 +315,10 @@ function reduceMetamask (state, action) {
coinOptions,
})
- case actions.TOGGLE_USE_BLOCKIE:
- return extend(metamaskState, {
- useBlockie: !metamaskState.useBlockie,
- })
+ case actions.SET_USE_BLOCKIE:
+ return extend(metamaskState, {
+ useBlockie: action.value
+ })
default:
return metamaskState
diff --git a/ui/app/settings.js b/ui/app/settings.js
index 793906bdb..949cbfb26 100644
--- a/ui/app/settings.js
+++ b/ui/app/settings.js
@@ -8,7 +8,7 @@ const validUrl = require('valid-url')
const { exportAsFile } = require('./util')
const TabBar = require('./components/tab-bar')
const SimpleDropdown = require('./components/dropdowns/simple-dropdown')
-import Switch from 'react-toggle-switch'
+const ToggleButton = require('react-toggle-button')
const getInfuraCurrencyOptions = () => {
const sortedCurrencies = infuraCurrencies.objects.sort((a, b) => {
@@ -53,7 +53,7 @@ class Settings extends Component {
}
renderBlockieOptIn () {
- const { metamask: { useBlockie }, toggleUseBlockie } = this.props
+ const { metamask: { useBlockie }, setUseBlockie } = this.props
return h('div.settings__content-row', [
h('div.settings__content-item', [
@@ -61,12 +61,12 @@ class Settings extends Component {
]),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
-
- h(Switch, {
- on: useBlockie,
- onClick: event => toggleUseBlockie(),
+ h(ToggleButton, {
+ value: useBlockie,
+ onToggle: (value) => setUseBlockie(!value),
+ activeLabel: '',
+ inactiveLabel: '',
}),
-
]),
]),
])
@@ -357,7 +357,7 @@ class Settings extends Component {
Settings.propTypes = {
tab: PropTypes.string,
metamask: PropTypes.object,
- useBlockie: PropTypes.bool,
+ setUseBlockie: PropTypes.func,
setCurrentCurrency: PropTypes.func,
setRpcTarget: PropTypes.func,
displayWarning: PropTypes.func,
@@ -370,7 +370,6 @@ const mapStateToProps = state => {
return {
metamask: state.metamask,
warning: state.appState.warning,
- useBlockie: state.useBlockie,
}
}
@@ -381,7 +380,7 @@ const mapDispatchToProps = dispatch => {
setRpcTarget: newRpc => dispatch(actions.setRpcTarget(newRpc)),
displayWarning: warning => dispatch(actions.displayWarning(warning)),
revealSeedConfirmation: () => dispatch(actions.revealSeedConfirmation()),
- toggleUseBlockie: () => dispatch(actions.toggleUseBlockie()),
+ setUseBlockie: value => dispatch(actions.setUseBlockie(value)),
}
}