From a9f08f50dac1f007b71adf53d1a8a2f26577a086 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Thu, 27 Jul 2017 06:16:09 -0700 Subject: [PATCH] basilisk refresh btn (wip) --- react/src/actions/actions/basiliskCache.js | 3 +- .../walletsBalance/walletsBalance.js | 28 +++++++++++++++++++ .../walletsBalance/walletsBalance.render.js | 3 ++ react/src/components/overrides.scss | 6 ++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/react/src/actions/actions/basiliskCache.js b/react/src/actions/actions/basiliskCache.js index 07a5713..00d4087 100644 --- a/react/src/actions/actions/basiliskCache.js +++ b/react/src/actions/actions/basiliskCache.js @@ -67,10 +67,11 @@ export function fetchNewCacheData(_payload) { _coin = `&coin=${_payload.coin}`, _calls = `&calls=${_payload.calls}`, _address = _payload.address ? (`&address=${_payload.address}`) : '', + _skip = _payload.skip ? (`&skip=${_payload.skip}`) : '', _iguanaInstancePort = Config.useBasiliskInstance ? `&port=${Config.iguanaCorePort + 1}` : ''; return dispatch => { - return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/${_route}${_userpass}${_pubkey}${_coin}${_calls}${_address}${_iguanaInstancePort}`, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/${_route}${_userpass}${_pubkey}${_coin}${_calls}${_address}${_skip}${_iguanaInstancePort}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.js b/react/src/components/dashboard/walletsBalance/walletsBalance.js index 1dab912..a3b7a31 100755 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.js @@ -1,12 +1,27 @@ import React from 'react'; import { translate } from '../../../translate/translate'; +import { fetchNewCacheData } from '../../../actions/actionCreators'; +import Store from '../../../store'; import WalletsBalanceRender from './walletsBalance.render'; class WalletsBalance extends React.Component { constructor(props) { super(props); + this.state = { + currentAddress: null, + }; this.isFullySynced = this.isFullySynced.bind(this); + this.refreshBalance = this.refreshBalance.bind(this); + } + + componentWillReceiveProps(props) { + if (!this.state.currentAddress && + this.props.ActiveCoin.activeAddress) { + this.setState(Object.assign({}, this.state, { + currentAddress: this.props.ActiveCoin.activeAddress, + })); + } } isFullySynced() { @@ -21,6 +36,19 @@ class WalletsBalance extends React.Component { } } + refreshBalance() { + if (this.props.ActiveCoin.mode === 'basilisk') { + Store.dispatch(fetchNewCacheData({ + 'pubkey': this.props.Dashboard.activeHandle.pubkey, + 'allcoins': false, + 'coin': this.props.ActiveCoin.coin, + 'calls': 'getbalance', + 'skip': true, + 'address': this.state.currentAddress, + })); + } + } + renderBalance(type) { let _balance = '0'; const _mode = this.props.ActiveCoin.mode; diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js index 5a97998..4664e40 100644 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js @@ -26,6 +26,9 @@ const WalletsBalanceRender = function() {
+
diff --git a/react/src/components/overrides.scss b/react/src/components/overrides.scss index 55cd8a3..d23281c 100644 --- a/react/src/components/overrides.scss +++ b/react/src/components/overrides.scss @@ -641,4 +641,10 @@ select{ .backround-gray { background: #f3f4f5; +} + +.manual-balance-refresh { + position: absolute; + right: 4px; + top: 3px; } \ No newline at end of file