Drop old txo-fetch results #396

Merged
infinite-persistence merged 1 commit from ip-txo-fetch-id into master 2021-03-24 02:35:10 +01:00
3 changed files with 50 additions and 9 deletions

29
dist/bundle.es.js vendored
View file

@ -2840,8 +2840,11 @@ function doFetchTransactions(page = 1, pageSize = 99999) {
function doFetchTxoPage() { function doFetchTxoPage() {
return (dispatch, getState) => { return (dispatch, getState) => {
const fetchId = Math.random().toString(36).substr(2, 9);
dispatch({ dispatch({
type: FETCH_TXO_PAGE_STARTED type: FETCH_TXO_PAGE_STARTED,
data: fetchId
}); });
const state = getState(); const state = getState();
@ -2873,12 +2876,18 @@ function doFetchTxoPage() {
}).then(res => { }).then(res => {
dispatch({ dispatch({
type: FETCH_TXO_PAGE_COMPLETED, type: FETCH_TXO_PAGE_COMPLETED,
data: res data: {
result: res,
fetchId: fetchId
}
}); });
}).catch(e => { }).catch(e => {
dispatch({ dispatch({
type: FETCH_TXO_PAGE_COMPLETED, type: FETCH_TXO_PAGE_COMPLETED,
data: e.message data: {
error: e.message,
fetchId: fetchId
}
}); });
}); });
}; };
@ -6073,6 +6082,7 @@ const defaultState$5 = {
massClaimingTips: false, massClaimingTips: false,
pendingMassClaimTxid: null, pendingMassClaimTxid: null,
txoPage: {}, txoPage: {},
fetchId: '',
fetchingTxos: false, fetchingTxos: false,
fetchingTxosError: undefined, fetchingTxosError: undefined,
pendingSupportTransactions: {}, pendingSupportTransactions: {},
@ -6100,16 +6110,24 @@ const walletReducer = handleActions({
}); });
}, },
[FETCH_TXO_PAGE_STARTED]: state => { [FETCH_TXO_PAGE_STARTED]: (state, action) => {
return _extends$d({}, state, { return _extends$d({}, state, {
fetchId: action.data,
fetchingTxos: true, fetchingTxos: true,
fetchingTxosError: undefined fetchingTxosError: undefined
}); });
}, },
[FETCH_TXO_PAGE_COMPLETED]: (state, action) => { [FETCH_TXO_PAGE_COMPLETED]: (state, action) => {
if (state.fetchId !== action.data.fetchId) {
// Leave 'state' and 'fetchingTxos' alone. The latter would ensure
// the spiner would continue spinning for the latest transaction.
return _extends$d({}, state);
}
return _extends$d({}, state, { return _extends$d({}, state, {
txoPage: action.data, txoPage: action.data.result,
fetchId: '',
fetchingTxos: false fetchingTxos: false
}); });
}, },
@ -6117,6 +6135,7 @@ const walletReducer = handleActions({
[FETCH_TXO_PAGE_FAILED]: (state, action) => { [FETCH_TXO_PAGE_FAILED]: (state, action) => {
return _extends$d({}, state, { return _extends$d({}, state, {
txoPage: {}, txoPage: {},
fetchId: '',
fetchingTxos: false, fetchingTxos: false,
fetchingTxosError: action.data fetchingTxosError: action.data
}); });

View file

@ -81,8 +81,13 @@ export function doFetchTransactions(page = 1, pageSize = 99999) {
export function doFetchTxoPage() { export function doFetchTxoPage() {
return (dispatch, getState) => { return (dispatch, getState) => {
const fetchId = Math.random()
.toString(36)
.substr(2, 9);
dispatch({ dispatch({
type: ACTIONS.FETCH_TXO_PAGE_STARTED, type: ACTIONS.FETCH_TXO_PAGE_STARTED,
data: fetchId,
}); });
const state = getState(); const state = getState();
@ -120,13 +125,19 @@ export function doFetchTxoPage() {
.then(res => { .then(res => {
dispatch({ dispatch({
type: ACTIONS.FETCH_TXO_PAGE_COMPLETED, type: ACTIONS.FETCH_TXO_PAGE_COMPLETED,
data: res, data: {
result: res,
fetchId: fetchId,
},
}); });
}) })
.catch(e => { .catch(e => {
dispatch({ dispatch({
type: ACTIONS.FETCH_TXO_PAGE_COMPLETED, type: ACTIONS.FETCH_TXO_PAGE_COMPLETED,
data: e.message, data: {
error: e.message,
fetchId: fetchId,
},
}); });
}); });
}; };

View file

@ -47,6 +47,7 @@ type WalletState = {
txoFetchParams: {}, txoFetchParams: {},
utxoCounts: {}, utxoCounts: {},
txoPage: any, txoPage: any,
fetchId: string,
fetchingTxos: boolean, fetchingTxos: boolean,
fetchingTxosError?: string, fetchingTxosError?: string,
consolidatingUtxos: boolean, consolidatingUtxos: boolean,
@ -99,6 +100,7 @@ const defaultState = {
massClaimingTips: false, massClaimingTips: false,
pendingMassClaimTxid: null, pendingMassClaimTxid: null,
txoPage: {}, txoPage: {},
fetchId: '',
fetchingTxos: false, fetchingTxos: false,
fetchingTxosError: undefined, fetchingTxosError: undefined,
pendingSupportTransactions: {}, pendingSupportTransactions: {},
@ -129,18 +131,26 @@ export const walletReducer = handleActions(
}; };
}, },
[ACTIONS.FETCH_TXO_PAGE_STARTED]: (state: WalletState) => { [ACTIONS.FETCH_TXO_PAGE_STARTED]: (state: WalletState, action) => {
return { return {
...state, ...state,
fetchId: action.data,
fetchingTxos: true, fetchingTxos: true,
fetchingTxosError: undefined, fetchingTxosError: undefined,
}; };
}, },
[ACTIONS.FETCH_TXO_PAGE_COMPLETED]: (state: WalletState, action) => { [ACTIONS.FETCH_TXO_PAGE_COMPLETED]: (state: WalletState, action) => {
if (state.fetchId !== action.data.fetchId) {
// Leave 'state' and 'fetchingTxos' alone. The latter would ensure
// the spiner would continue spinning for the latest transaction.
return { ...state };
}
return { return {
...state, ...state,
txoPage: action.data, txoPage: action.data.result,
fetchId: '',
fetchingTxos: false, fetchingTxos: false,
}; };
}, },
@ -149,6 +159,7 @@ export const walletReducer = handleActions(
return { return {
...state, ...state,
txoPage: {}, txoPage: {},
fetchId: '',
fetchingTxos: false, fetchingTxos: false,
fetchingTxosError: action.data, fetchingTxosError: action.data,
}; };