diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 0a5e917..3e7cffa 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -65,6 +65,7 @@ const ABANDON_SUPPORT_COMPLETED = 'ABANDON_SUPPORT_COMPLETED'; const ABANDON_CLAIM_SUPPORT_STARTED = 'ABANDON_CLAIM_SUPPORT_STARTED'; const ABANDON_CLAIM_SUPPORT_COMPLETED = 'ABANDON_CLAIM_SUPPORT_COMPLETED'; const ABANDON_CLAIM_SUPPORT_FAILED = 'ABANDON_CLAIM_SUPPORT_FAILED'; +const ABANDON_CLAIM_SUPPORT_PREVIEW = 'ABANDON_CLAIM_SUPPORT_PREVIEW'; const PENDING_SUPPORTS_UPDATED = 'PENDING_SUPPORTS_UPDATED'; const UPDATE_BALANCE = 'UPDATE_BALANCE'; const UPDATE_TOTAL_BALANCE = 'UPDATE_TOTAL_BALANCE'; @@ -334,6 +335,7 @@ var action_types = /*#__PURE__*/Object.freeze({ ABANDON_CLAIM_SUPPORT_STARTED: ABANDON_CLAIM_SUPPORT_STARTED, ABANDON_CLAIM_SUPPORT_COMPLETED: ABANDON_CLAIM_SUPPORT_COMPLETED, ABANDON_CLAIM_SUPPORT_FAILED: ABANDON_CLAIM_SUPPORT_FAILED, + ABANDON_CLAIM_SUPPORT_PREVIEW: ABANDON_CLAIM_SUPPORT_PREVIEW, PENDING_SUPPORTS_UPDATED: PENDING_SUPPORTS_UPDATED, UPDATE_BALANCE: UPDATE_BALANCE, UPDATE_TOTAL_BALANCE: UPDATE_TOTAL_BALANCE, @@ -1801,6 +1803,8 @@ const selectWalletEncryptSucceeded = reselect.createSelector(selectState$1, stat const selectPendingSupportTransactions = reselect.createSelector(selectState$1, state => state.pendingSupportTransactions); +const selectAbandonClaimSupportError = reselect.createSelector(selectState$1, state => state.abandonClaimSupportError); + const makeSelectPendingAmountByUri = uri => reselect.createSelector(selectClaimIdsByUri, selectPendingSupportTransactions, (claimIdsByUri, pendingSupports) => { const uriEntry = Object.entries(claimIdsByUri).find(([u, cid]) => u === uri); const claimId = uriEntry && uriEntry[1]; @@ -2821,11 +2825,16 @@ function doWalletUnlock(password) { function doSupportAbandonForClaim(claimId, claimType, keep, preview) { return dispatch => { - if (!preview) { + if (preview) { + dispatch({ + type: ABANDON_CLAIM_SUPPORT_PREVIEW + }); + } else { dispatch({ type: ABANDON_CLAIM_SUPPORT_STARTED }); } + const params = { claim_id: claimId }; if (preview) params['preview'] = true; if (keep) params['keep'] = keep; @@ -5919,7 +5928,8 @@ const defaultState$a = { walletLockResult: null, transactionListFilter: 'all', walletReconnecting: false, - pendingSupportTransactions: {} + pendingSupportTransactions: {}, + abandonClaimSupportError: undefined }; const walletReducer = handleActions({ @@ -5982,6 +5992,18 @@ const walletReducer = handleActions({ }); }, + [ABANDON_CLAIM_SUPPORT_STARTED]: (state, action) => { + return _extends$i({}, state, { + abandonClaimSupportError: undefined + }); + }, + + [ABANDON_CLAIM_SUPPORT_PREVIEW]: (state, action) => { + return _extends$i({}, state, { + abandonClaimSupportError: undefined + }); + }, + [ABANDON_CLAIM_SUPPORT_COMPLETED]: (state, action) => { const { claimId, type, txid, effective } = action.data; const pendingtxs = Object.assign({}, state.pendingSupportTransactions); @@ -5989,7 +6011,14 @@ const walletReducer = handleActions({ pendingtxs[claimId] = { txid, type, effective }; return _extends$i({}, state, { - pendingSupportTransactions: pendingtxs + pendingSupportTransactions: pendingtxs, + abandonClaimSupportError: undefined + }); + }, + + [ABANDON_CLAIM_SUPPORT_FAILED]: (state, action) => { + return _extends$i({}, state, { + abandonClaimSupportError: action.data }); }, @@ -6466,6 +6495,7 @@ exports.regexAddress = regexAddress; exports.regexInvalidURI = regexInvalidURI; exports.savePosition = savePosition; exports.searchReducer = searchReducer; +exports.selectAbandonClaimSupportError = selectAbandonClaimSupportError; exports.selectAbandoningIds = selectAbandoningIds; exports.selectAllClaimsByChannel = selectAllClaimsByChannel; exports.selectAllFetchingChannelClaims = selectAllFetchingChannelClaims; diff --git a/src/constants/action_types.js b/src/constants/action_types.js index 05eba19..ee82147 100644 --- a/src/constants/action_types.js +++ b/src/constants/action_types.js @@ -42,6 +42,7 @@ export const ABANDON_SUPPORT_COMPLETED = 'ABANDON_SUPPORT_COMPLETED'; export const ABANDON_CLAIM_SUPPORT_STARTED = 'ABANDON_CLAIM_SUPPORT_STARTED'; export const ABANDON_CLAIM_SUPPORT_COMPLETED = 'ABANDON_CLAIM_SUPPORT_COMPLETED'; export const ABANDON_CLAIM_SUPPORT_FAILED = 'ABANDON_CLAIM_SUPPORT_FAILED'; +export const ABANDON_CLAIM_SUPPORT_PREVIEW = 'ABANDON_CLAIM_SUPPORT_PREVIEW'; export const PENDING_SUPPORTS_UPDATED = 'PENDING_SUPPORTS_UPDATED'; export const UPDATE_BALANCE = 'UPDATE_BALANCE'; export const UPDATE_TOTAL_BALANCE = 'UPDATE_TOTAL_BALANCE'; diff --git a/src/index.js b/src/index.js index 8b26154..d1096ff 100644 --- a/src/index.js +++ b/src/index.js @@ -332,6 +332,7 @@ export { selectFilteredTransactionCount, selectIsWalletReconnecting, selectPendingSupportTransactions, + selectAbandonClaimSupportError, makeSelectPendingAmountByUri, } from 'redux/selectors/wallet'; diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index d4af422..627316b 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -345,11 +345,16 @@ export function doWalletLock() { export function doSupportAbandonForClaim(claimId, claimType, keep, preview) { return dispatch => { - if (!preview) { + if (preview) { + dispatch({ + type: ACTIONS.ABANDON_CLAIM_SUPPORT_PREVIEW, + }); + } else { dispatch({ type: ACTIONS.ABANDON_CLAIM_SUPPORT_STARTED, }); } + const params = {claim_id: claimId}; if (preview) params['preview'] = true; if (keep) params['keep'] = keep; diff --git a/src/redux/reducers/wallet.js b/src/redux/reducers/wallet.js index dc5553f..5a97e8a 100644 --- a/src/redux/reducers/wallet.js +++ b/src/redux/reducers/wallet.js @@ -46,6 +46,7 @@ type WalletState = { walletLockResult: ?boolean, walletReconnecting: boolean, pendingSupportTransactions: {}, // { claimId: {txid: 123, amount 12.3}, } + abandonClaimSupportError?: string, }; const defaultState = { @@ -80,6 +81,7 @@ const defaultState = { transactionListFilter: 'all', walletReconnecting: false, pendingSupportTransactions: {}, + abandonClaimSupportError: undefined, }; export const walletReducer = handleActions( @@ -148,6 +150,20 @@ export const walletReducer = handleActions( }; }, + [ACTIONS.ABANDON_CLAIM_SUPPORT_STARTED]: (state: WalletState, action: any): WalletState => { + return { + ...state, + abandonClaimSupportError: undefined, + }; + }, + + [ACTIONS.ABANDON_CLAIM_SUPPORT_PREVIEW]: (state: WalletState, action: any): WalletState => { + return { + ...state, + abandonClaimSupportError: undefined, + }; + }, + [ACTIONS.ABANDON_CLAIM_SUPPORT_COMPLETED]: (state: WalletState, action: any): WalletState => { const { claimId, type, txid, effective }: { claimId: string, type: string, txid: string, effective: string } = action.data; const pendingtxs = Object.assign({}, state.pendingSupportTransactions); @@ -157,6 +173,14 @@ export const walletReducer = handleActions( return { ...state, pendingSupportTransactions: pendingtxs, + abandonClaimSupportError: undefined, + }; + }, + + [ACTIONS.ABANDON_CLAIM_SUPPORT_FAILED]: (state: WalletState, action: any): WalletState => { + return { + ...state, + abandonClaimSupportError: action.data, }; }, diff --git a/src/redux/selectors/wallet.js b/src/redux/selectors/wallet.js index 38347d7..4da48db 100644 --- a/src/redux/selectors/wallet.js +++ b/src/redux/selectors/wallet.js @@ -26,6 +26,11 @@ export const selectPendingSupportTransactions = createSelector( state => state.pendingSupportTransactions ); +export const selectAbandonClaimSupportError = createSelector( + selectState, + state => state.abandonClaimSupportError +); + export const makeSelectPendingAmountByUri = (uri) => createSelector( selectClaimIdsByUri, selectPendingSupportTransactions,