From be082d751d0eb5ebefd0ff2b1662872a4b780d51 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Mon, 20 Nov 2017 19:18:13 +0300 Subject: [PATCH] proper coin removal from app state --- react/src/actions/actionCreators.js | 8 ++++++++ react/src/actions/storeType.js | 3 ++- react/src/components/dashboard/coinTile/coinTileItem.js | 4 ++++ .../dashboard/receiveCoin/receiveCoin.render.js | 2 +- react/src/reducers/activeCoin.js | 8 ++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index ff46bf5..8df7dbf 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -29,6 +29,7 @@ import { DISPLAY_IMPORT_KEY_MODAL, ELECTRUM_SERVER_CHANGED, DISPLAY_ZCASH_PARAMS_FETCH, + DASHBOARD_REMOVE_COIN, } from './storeType'; export * from './actions/nativeSyncInfo'; @@ -288,4 +289,11 @@ export function toggleZcparamsFetchModal(display) { type: DISPLAY_ZCASH_PARAMS_FETCH, displayZcparamsModal: display, } +} + +export function dashboardRemoveCoin(coin) { + return { + type: DASHBOARD_REMOVE_COIN, + coin, + } } \ No newline at end of file diff --git a/react/src/actions/storeType.js b/react/src/actions/storeType.js index f3860b3..02c3c10 100644 --- a/react/src/actions/storeType.js +++ b/react/src/actions/storeType.js @@ -46,4 +46,5 @@ export const DASHBOARD_ELECTRUM_BALANCE = 'DASHBOARD_ELECTRUM_BALANCE'; export const DASHBOARD_ELECTRUM_TRANSACTIONS = 'DASHBOARD_ELECTRUM_TRANSACTIONS'; export const DASHBOARD_ELECTRUM_COINS = 'DASHBOARD_ELECTRUM_COINS'; export const ELECTRUM_SERVER_CHANGED = 'ELECTRUM_SERVER_CHANGED'; -export const DISPLAY_ZCASH_PARAMS_FETCH = 'DISPLAY_ZCASH_PARAMS_FETCH'; \ No newline at end of file +export const DISPLAY_ZCASH_PARAMS_FETCH = 'DISPLAY_ZCASH_PARAMS_FETCH'; +export const DASHBOARD_REMOVE_COIN = 'DASHBOARD_REMOVE_COIN'; \ No newline at end of file diff --git a/react/src/components/dashboard/coinTile/coinTileItem.js b/react/src/components/dashboard/coinTile/coinTileItem.js index 12b8241..8dc431e 100644 --- a/react/src/components/dashboard/coinTile/coinTileItem.js +++ b/react/src/components/dashboard/coinTile/coinTileItem.js @@ -25,6 +25,7 @@ import { triggerToaster, shepherdRemoveCoin, toggleCoindDownModal, + dashboardRemoveCoin, } from '../../../actions/actionCreators'; import Store from '../../../store'; import Config from '../../../config'; @@ -151,6 +152,8 @@ class CoinTileItem extends React.Component { 'success' ) ); + + Store.dispatch(dashboardRemoveCoin(coin)); Store.dispatch(getDexCoins()); Store.dispatch(activeHandle()); setTimeout(() => { @@ -179,6 +182,7 @@ class CoinTileItem extends React.Component { ) ); + Store.dispatch(dashboardRemoveCoin(coin)); Store.dispatch(getDexCoins()); Store.dispatch(activeHandle()); setTimeout(() => { diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.render.js b/react/src/components/dashboard/receiveCoin/receiveCoin.render.js index 9c5a8a7..e4c4b7c 100644 --- a/react/src/components/dashboard/receiveCoin/receiveCoin.render.js +++ b/react/src/components/dashboard/receiveCoin/receiveCoin.render.js @@ -24,7 +24,7 @@ export const AddressActionsNonBasiliskModeRender = function(address, type) {
  • this._copyCoinAddress(address) }> { translate('INDEX.COPY') + ' pub key' }
  • - { address[0] !== 'b' && + { !address.canspend &&
  • this.dumpPrivKey(address) }> { translate('INDEX.COPY') + ' priv key (WIF)' }
  • diff --git a/react/src/reducers/activeCoin.js b/react/src/reducers/activeCoin.js index 4b88843..07b1b55 100644 --- a/react/src/reducers/activeCoin.js +++ b/react/src/reducers/activeCoin.js @@ -17,6 +17,7 @@ import { DASHBOARD_UPDATE, DASHBOARD_ELECTRUM_BALANCE, DASHBOARD_ELECTRUM_TRANSACTIONS, + DASHBOARD_REMOVE_COIN, } from '../actions/storeType'; // TODO: refactor current coin props copy on change @@ -40,6 +41,13 @@ export function ActiveCoin(state = { getinfoFetchFailures: 0, }, action) { switch (action.type) { + case DASHBOARD_REMOVE_COIN: + let _coins = state.coins; + delete _coins[action.coin]; + return { + ...state, + coins: _coins, + } case DASHBOARD_ACTIVE_COIN_CHANGE: if (state.coins[action.coin]) { const _coinData = state.coins[action.coin];