better track txids for large wallet operations #380
5 changed files with 102 additions and 15 deletions
52
dist/bundle.es.js
vendored
52
dist/bundle.es.js
vendored
|
@ -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;
|
||||
|
|
|
@ -321,4 +321,6 @@ export {
|
|||
selectIsMassClaimingTips,
|
||||
selectUtxoCounts,
|
||||
selectPendingOtherTransactions,
|
||||
selectPendingConsolidateTxid,
|
||||
selectPendingMassClaimTxid,
|
||||
} from 'redux/selectors/wallet';
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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<string>,
|
||||
pendingTxos: Array<string>,
|
||||
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) };
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue