Browse Source

proper coin removal from app state

v0.25
pbca26 7 years ago
parent
commit
be082d751d
  1. 8
      react/src/actions/actionCreators.js
  2. 3
      react/src/actions/storeType.js
  3. 4
      react/src/components/dashboard/coinTile/coinTileItem.js
  4. 2
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js
  5. 8
      react/src/reducers/activeCoin.js

8
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,
}
}

3
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';
export const DISPLAY_ZCASH_PARAMS_FETCH = 'DISPLAY_ZCASH_PARAMS_FETCH';
export const DASHBOARD_REMOVE_COIN = 'DASHBOARD_REMOVE_COIN';

4
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(() => {

2
react/src/components/dashboard/receiveCoin/receiveCoin.render.js

@ -24,7 +24,7 @@ export const AddressActionsNonBasiliskModeRender = function(address, type) {
<li onClick={ () => this._copyCoinAddress(address) }>
<i className="icon wb-copy margin-right-5"></i> { translate('INDEX.COPY') + ' pub key' }
</li>
{ address[0] !== 'b' &&
{ !address.canspend &&
<li onClick={ () => this.dumpPrivKey(address) }>
<i className="icon fa-key margin-right-5"></i> { translate('INDEX.COPY') + ' priv key (WIF)' }
</li>

8
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];

Loading…
Cancel
Save