From de41f6bb8e04ec70433196224b748c6e5fd40819 Mon Sep 17 00:00:00 2001 From: jessop Date: Wed, 1 Apr 2020 14:26:38 -0400 Subject: [PATCH 1/2] adds abandonClaiSupportError to wallet reducer --- dist/bundle.es.js | 30 +++++++++++++++++++++++------- src/index.js | 1 + src/redux/actions/wallet.js | 9 ++++----- src/redux/reducers/wallet.js | 17 +++++++++++++++++ src/redux/selectors/wallet.js | 5 +++++ 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 0a5e917..1e2e361 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1801,6 +1801,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 +2823,10 @@ function doWalletUnlock(password) { function doSupportAbandonForClaim(claimId, claimType, keep, preview) { return dispatch => { - if (!preview) { - dispatch({ - type: ABANDON_CLAIM_SUPPORT_STARTED - }); - } + dispatch({ + type: ABANDON_CLAIM_SUPPORT_STARTED + }); + const params = { claim_id: claimId }; if (preview) params['preview'] = true; if (keep) params['keep'] = keep; @@ -5919,7 +5920,8 @@ const defaultState$a = { walletLockResult: null, transactionListFilter: 'all', walletReconnecting: false, - pendingSupportTransactions: {} + pendingSupportTransactions: {}, + abandonClaimSupportError: undefined }; const walletReducer = handleActions({ @@ -5982,6 +5984,12 @@ const walletReducer = handleActions({ }); }, + [ABANDON_CLAIM_SUPPORT_STARTED]: (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 +5997,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 +6481,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/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..16d4a5c 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -345,11 +345,10 @@ export function doWalletLock() { export function doSupportAbandonForClaim(claimId, claimType, keep, preview) { return dispatch => { - if (!preview) { - dispatch({ - type: ACTIONS.ABANDON_CLAIM_SUPPORT_STARTED, - }); - } + 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..d718fc4 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,13 @@ export const walletReducer = handleActions( }; }, + [ACTIONS.ABANDON_CLAIM_SUPPORT_STARTED]: (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 +166,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, From 1097a63d44a20b87e443fbaa48f95fe3ea5e3f70 Mon Sep 17 00:00:00 2001 From: jessop Date: Wed, 1 Apr 2020 14:36:11 -0400 Subject: [PATCH 2/2] add preview action --- dist/bundle.es.js | 20 +++++++++++++++++--- src/constants/action_types.js | 1 + src/redux/actions/wallet.js | 12 +++++++++--- src/redux/reducers/wallet.js | 7 +++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 1e2e361..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, @@ -2823,9 +2825,15 @@ function doWalletUnlock(password) { function doSupportAbandonForClaim(claimId, claimType, keep, preview) { return dispatch => { - dispatch({ - type: ABANDON_CLAIM_SUPPORT_STARTED - }); + 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; @@ -5990,6 +5998,12 @@ const walletReducer = handleActions({ }); }, + [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); 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/redux/actions/wallet.js b/src/redux/actions/wallet.js index 16d4a5c..627316b 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -345,9 +345,15 @@ export function doWalletLock() { export function doSupportAbandonForClaim(claimId, claimType, keep, preview) { return dispatch => { - dispatch({ - type: ACTIONS.ABANDON_CLAIM_SUPPORT_STARTED, - }); + 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; diff --git a/src/redux/reducers/wallet.js b/src/redux/reducers/wallet.js index d718fc4..5a97e8a 100644 --- a/src/redux/reducers/wallet.js +++ b/src/redux/reducers/wallet.js @@ -157,6 +157,13 @@ export const walletReducer = handleActions( }; }, + [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);