diff --git a/dist/bundle.es.js b/dist/bundle.es.js index a2f9420..f26168b 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1931,7 +1931,7 @@ const selectWalletEncryptSucceeded = reselect.createSelector(selectState, state const selectPendingSupportTransactions = reselect.createSelector(selectState, state => state.pendingSupportTransactions); -const selectPendingOtherTransactions = reselect.createSelector(selectState, state => state.pendingConsolidateTxos); +const selectPendingOtherTransactions = reselect.createSelector(selectState, state => state.pendingTxos); const selectAbandonClaimSupportError = reselect.createSelector(selectState, state => state.abandonClaimSupportError); @@ -2128,6 +2128,10 @@ const selectIsConsolidatingUtxos = reselect.createSelector(selectState, state => const selectIsMassClaimingTips = reselect.createSelector(selectState, state => state.massClaimingTips); +const selectPendingConsolidateTxid = reselect.createSelector(selectState, state => state.pendingConsolidateTxid); + +const selectPendingMassClaimTxid = reselect.createSelector(selectState, state => state.pendingMassClaimTxid); + const selectUtxoCounts = reselect.createSelector(selectState, state => state.utxoCounts); var _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; @@ -2876,7 +2880,8 @@ function doUtxoConsolidate() { }); dispatch({ - type: DO_UTXO_CONSOLIDATE_COMPLETED + type: DO_UTXO_CONSOLIDATE_COMPLETED, + data: { txid: result.txid } }); dispatch(doCheckPendingTxs()); }); @@ -2903,7 +2908,8 @@ function doTipClaimMass() { }); dispatch({ - type: TIP_CLAIM_MASS_COMPLETED + type: TIP_CLAIM_MASS_COMPLETED, + data: { txid: result.txid } }); dispatch(doCheckPendingTxs()); }); @@ -3257,6 +3263,8 @@ const doCheckPendingTxs = () => (dispatch, getState) => { const state = getState(); const pendingSupportTxs = selectPendingSupportTransactions(state); // {} const pendingConsolidateTxes = selectPendingOtherTransactions(state); + const pendingConsTxid = selectPendingConsolidateTxid(state); + const pendingMassCLaimTxid = selectPendingMassClaimTxid(state); const promises = []; const newPendingTxes = {}; @@ -3302,6 +3310,18 @@ const doCheckPendingTxs = () => (dispatch, getState) => { } } if (noLongerPendingConsolidate.length) { + if (noLongerPendingConsolidate.includes(pendingConsTxid)) { + dispatch(doToast({ + title: __('Wallet Job'), + message: __('Your wallet is finished consolidating') + })); + } + if (noLongerPendingConsolidate.includes(pendingMassCLaimTxid)) { + dispatch(doToast({ + title: __('Wallet Job'), + message: __('Your tips have been collected') + })); + } dispatch({ type: PENDING_CONSOLIDATED_TXOS_UPDATED, data: { txids: noLongerPendingConsolidate, remove: true } @@ -5989,12 +6009,14 @@ const defaultState$5 = { fetchingUtxoCounts: false, fetchingUtxoError: undefined, consolidatingUtxos: false, + pendingConsolidateTxid: null, massClaimingTips: false, + pendingMassClaimTxid: null, txoPage: {}, fetchingTxos: false, fetchingTxosError: undefined, pendingSupportTransactions: {}, - pendingConsolidateTxos: [], + pendingTxos: [], abandonClaimSupportError: undefined }; @@ -6066,8 +6088,10 @@ const walletReducer = handleActions({ }, [DO_UTXO_CONSOLIDATE_COMPLETED]: (state, action) => { + const { txid } = action.data; return _extends$d({}, state, { - consolidatingUtxos: false + consolidatingUtxos: false, + pendingConsolidateTxid: txid }); }, @@ -6084,8 +6108,10 @@ const walletReducer = handleActions({ }, [TIP_CLAIM_MASS_COMPLETED]: (state, action) => { + const { txid } = action.data; return _extends$d({}, state, { - massClaimingTips: false + massClaimingTips: false, + pendingMassClaimTxid: txid }); }, @@ -6096,16 +6122,22 @@ const walletReducer = handleActions({ }, [PENDING_CONSOLIDATED_TXOS_UPDATED]: (state, action) => { - const pendingTxos = state.pendingConsolidateTxos; + const { pendingTxos, pendingMassClaimTxid, pendingConsolidateTxid } = state; const { txids, remove } = action.data; if (remove) { const newTxos = pendingTxos.filter(txo => !txids.includes(txo)); - return _extends$d({}, state, { pendingConsolidateTxos: newTxos }); + const newPendingMassClaimTxid = txids.includes(pendingMassClaimTxid) ? undefined : pendingMassClaimTxid; + const newPendingConsolidateTxid = txids.includes(pendingConsolidateTxid) ? undefined : pendingConsolidateTxid; + return _extends$d({}, state, { + pendingTxos: newTxos, + pendingMassClaimTxid: newPendingMassClaimTxid, + pendingConsolidateTxid: newPendingConsolidateTxid + }); } else { const newPendingSet = new Set([...pendingTxos, ...txids]); - return _extends$d({}, state, { pendingConsolidateTxos: Array.from(newPendingSet) }); + return _extends$d({}, state, { pendingTxos: Array.from(newPendingSet) }); } }, @@ -6634,7 +6666,9 @@ exports.selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels; exports.selectMyPurchases = selectMyPurchases; exports.selectMyPurchasesCount = selectMyPurchasesCount; exports.selectMyStreamUrlsCount = selectMyStreamUrlsCount; +exports.selectPendingConsolidateTxid = selectPendingConsolidateTxid; exports.selectPendingIds = selectPendingIds; +exports.selectPendingMassClaimTxid = selectPendingMassClaimTxid; exports.selectPendingOtherTransactions = selectPendingOtherTransactions; exports.selectPendingSupportTransactions = selectPendingSupportTransactions; exports.selectPlayingUri = selectPlayingUri; diff --git a/src/index.js b/src/index.js index 9117d29..5464d69 100644 --- a/src/index.js +++ b/src/index.js @@ -321,4 +321,6 @@ export { selectIsMassClaimingTips, selectUtxoCounts, selectPendingOtherTransactions, + selectPendingConsolidateTxid, + selectPendingMassClaimTxid, } from 'redux/selectors/wallet'; diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index 02b9227..b8bbe0f 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -6,6 +6,8 @@ import { selectPendingSupportTransactions, selectTxoPageParams, selectPendingOtherTransactions, + selectPendingConsolidateTxid, + selectPendingMassClaimTxid, } from 'redux/selectors/wallet'; import { creditsToString } from 'util/format-credits'; import { selectMyClaimsRaw } from 'redux/selectors/claims'; @@ -169,6 +171,7 @@ export function doUtxoConsolidate() { dispatch({ type: ACTIONS.DO_UTXO_CONSOLIDATE_COMPLETED, + data: { txid: result.txid }, }); dispatch(doCheckPendingTxs()); }; @@ -190,6 +193,7 @@ export function doTipClaimMass() { dispatch({ type: ACTIONS.TIP_CLAIM_MASS_COMPLETED, + data: { txid: result.txid }, }); dispatch(doCheckPendingTxs()); }; @@ -585,6 +589,8 @@ export const doCheckPendingTxs = () => (dispatch, getState) => { const state = getState(); const pendingSupportTxs = selectPendingSupportTransactions(state); // {} const pendingConsolidateTxes = selectPendingOtherTransactions(state); + const pendingConsTxid = selectPendingConsolidateTxid(state); + const pendingMassCLaimTxid = selectPendingMassClaimTxid(state); const promises = []; const newPendingTxes = {}; @@ -630,6 +636,20 @@ export const doCheckPendingTxs = () => (dispatch, getState) => { } } if (noLongerPendingConsolidate.length) { + if (noLongerPendingConsolidate.includes(pendingConsTxid)) { + dispatch( + doToast({ + message: __('Your wallet is finished consolidating'), + }) + ); + } + if (noLongerPendingConsolidate.includes(pendingMassCLaimTxid)) { + dispatch( + doToast({ + message: __('Your tips have been collected'), + }) + ); + } dispatch({ type: ACTIONS.PENDING_CONSOLIDATED_TXOS_UPDATED, data: { txids: noLongerPendingConsolidate, remove: true }, diff --git a/src/redux/reducers/wallet.js b/src/redux/reducers/wallet.js index e6b56ef..de5ac68 100644 --- a/src/redux/reducers/wallet.js +++ b/src/redux/reducers/wallet.js @@ -49,8 +49,12 @@ type WalletState = { txoPage: any, fetchingTxos: boolean, fetchingTxosError?: string, + consolidatingUtxos: boolean, + pendingConsolidateTxid?: string, + massClaimingTips: boolean, + pendingMassClaimTxid?: string, pendingSupportTransactions: {}, // { claimId: {txid: 123, amount 12.3}, } - pendingConsolidateTxos: Array, + pendingTxos: Array, abandonClaimSupportError?: string, }; @@ -91,12 +95,14 @@ const defaultState = { fetchingUtxoCounts: false, fetchingUtxoError: undefined, consolidatingUtxos: false, + pendingConsolidateTxid: null, massClaimingTips: false, + pendingMassClaimTxid: null, txoPage: {}, fetchingTxos: false, fetchingTxosError: undefined, pendingSupportTransactions: {}, - pendingConsolidateTxos: [], + pendingTxos: [], abandonClaimSupportError: undefined, }; @@ -178,9 +184,11 @@ export const walletReducer = handleActions( }, [ACTIONS.DO_UTXO_CONSOLIDATE_COMPLETED]: (state: WalletState, action) => { + const { txid } = action.data; return { ...state, consolidatingUtxos: false, + pendingConsolidateTxid: txid, }; }, @@ -199,9 +207,11 @@ export const walletReducer = handleActions( }, [ACTIONS.TIP_CLAIM_MASS_COMPLETED]: (state: WalletState, action) => { + const { txid } = action.data; return { ...state, massClaimingTips: false, + pendingMassClaimTxid: txid, }; }, @@ -213,16 +223,27 @@ export const walletReducer = handleActions( }, [ACTIONS.PENDING_CONSOLIDATED_TXOS_UPDATED]: (state: WalletState, action) => { - const pendingTxos = state.pendingConsolidateTxos; + const { pendingTxos, pendingMassClaimTxid, pendingConsolidateTxid } = state; const { txids, remove } = action.data; if (remove) { const newTxos = pendingTxos.filter(txo => !txids.includes(txo)); - return { ...state, pendingConsolidateTxos: newTxos }; + const newPendingMassClaimTxid = txids.includes(pendingMassClaimTxid) + ? undefined + : pendingMassClaimTxid; + const newPendingConsolidateTxid = txids.includes(pendingConsolidateTxid) + ? undefined + : pendingConsolidateTxid; + return { + ...state, + pendingTxos: newTxos, + pendingMassClaimTxid: newPendingMassClaimTxid, + pendingConsolidateTxid: newPendingConsolidateTxid, + }; } else { const newPendingSet = new Set([...pendingTxos, ...txids]); - return { ...state, pendingConsolidateTxos: Array.from(newPendingSet) }; + return { ...state, pendingTxos: Array.from(newPendingSet) }; } }, diff --git a/src/redux/selectors/wallet.js b/src/redux/selectors/wallet.js index 5e2c61b..89316d7 100644 --- a/src/redux/selectors/wallet.js +++ b/src/redux/selectors/wallet.js @@ -28,7 +28,7 @@ export const selectPendingSupportTransactions = createSelector( export const selectPendingOtherTransactions = createSelector( selectState, - state => state.pendingConsolidateTxos + state => state.pendingTxos ); export const selectAbandonClaimSupportError = createSelector( @@ -401,6 +401,16 @@ export const selectIsMassClaimingTips = createSelector( state => state.massClaimingTips ); +export const selectPendingConsolidateTxid = createSelector( + selectState, + state => state.pendingConsolidateTxid +); + +export const selectPendingMassClaimTxid = createSelector( + selectState, + state => state.pendingMassClaimTxid +); + export const selectUtxoCounts = createSelector( selectState, state => state.utxoCounts