diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index bcf9a16..d41cf07 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -1753,6 +1753,47 @@ export function createNewWallet(_passphrase) { } } +export function deleteCacheFile(_payload) { + return dispatch => { + return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?', { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'filename': _payload.pubkey }), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'deleteCacheFile', 'Error', 'error')) + }) + .then(response => response.json()) + .then(json => dispatch(fetchNewCacheData(_payload))); + } +} + +export function fetchNewCacheData(_payload) { + const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); + const _pubkey = '&pubkey=' + _payload.pubkey; + const _route = _payload.allcoins ? 'cache-all' : 'cache-one'; + const _coin = '&coin=' + _payload.coin; + const _calls = '&calls=' + _payload.calls; + + return dispatch => { + return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => console.log(json)) + } +} + /*function Shepherd_SendPendValue() { Shepherd_SysInfo().then(function(result){ var ram_data = formatBytes(result.totalmem_bytes) diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index ce15741..c5636e6 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -8,7 +8,8 @@ import { toggleDashboardTxInfoModal, getBasiliskTransactionsList, changeMainBasiliskAddress, - displayNotariesModal + displayNotariesModal, + deleteCacheFile } from '../../actions/actionCreators'; import Store from '../../store'; @@ -41,6 +42,7 @@ class WalletsData extends React.Component { this.getDexNotariesAction = this.getDexNotariesAction.bind(this); this.openDropMenu = this.openDropMenu.bind(this); this.refreshTxList = this.refreshTxList.bind(this); + this.removeAndfetchNewCache = this.removeAndfetchNewCache.bind(this); socket.on('messages', msg => this.updateSocketsData(msg)); } @@ -64,6 +66,15 @@ class WalletsData extends React.Component { } } + removeAndfetchNewCache() { + Store.dispatch(deleteCacheFile({ + 'pubkey': this.props.Dashboard.activeHandle.pubkey, + 'allcoins': false, + 'coin': this.props.ActiveCoin.coin, + 'calls': 'listtransactions:getbalance', + })); + } + toggleBasiliskActionsMenu() { this.setState(Object.assign({}, this.state, { basiliskActionsMenu: !this.state.basiliskActionsMenu, @@ -374,7 +385,7 @@ class WalletsData extends React.Component {