Merge pull request #396 from lbryio/ip-txo-fetch-id

Drop old txo-fetch results
This commit is contained in:
Thomas Zarebczan 2021-03-23 21:35:10 -04:00 committed by GitHub
commit 86c7741d4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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() {
return (dispatch, getState) => {
const fetchId = Math.random().toString(36).substr(2, 9);
dispatch({
type: FETCH_TXO_PAGE_STARTED
type: FETCH_TXO_PAGE_STARTED,
data: fetchId
});
const state = getState();
@ -2873,12 +2876,18 @@ function doFetchTxoPage() {
}).then(res => {
dispatch({
type: FETCH_TXO_PAGE_COMPLETED,
data: res
data: {
result: res,
fetchId: fetchId
}
});
}).catch(e => {
dispatch({
type: FETCH_TXO_PAGE_COMPLETED,
data: e.message
data: {
error: e.message,
fetchId: fetchId
}
});
});
};
@ -6073,6 +6082,7 @@ const defaultState$5 = {
massClaimingTips: false,
pendingMassClaimTxid: null,
txoPage: {},
fetchId: '',
fetchingTxos: false,
fetchingTxosError: undefined,
pendingSupportTransactions: {},
@ -6100,16 +6110,24 @@ const walletReducer = handleActions({
});
},
[FETCH_TXO_PAGE_STARTED]: state => {
[FETCH_TXO_PAGE_STARTED]: (state, action) => {
return _extends$d({}, state, {
fetchId: action.data,
fetchingTxos: true,
fetchingTxosError: undefined
});
},
[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, {
txoPage: action.data,
txoPage: action.data.result,
fetchId: '',
fetchingTxos: false
});
},
@ -6117,6 +6135,7 @@ const walletReducer = handleActions({
[FETCH_TXO_PAGE_FAILED]: (state, action) => {
return _extends$d({}, state, {
txoPage: {},
fetchId: '',
fetchingTxos: false,
fetchingTxosError: action.data
});

View file

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

View file

@ -47,6 +47,7 @@ type WalletState = {
txoFetchParams: {},
utxoCounts: {},
txoPage: any,
fetchId: string,
fetchingTxos: boolean,
fetchingTxosError?: string,
consolidatingUtxos: boolean,
@ -99,6 +100,7 @@ const defaultState = {
massClaimingTips: false,
pendingMassClaimTxid: null,
txoPage: {},
fetchId: '',
fetchingTxos: false,
fetchingTxosError: undefined,
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 {
...state,
fetchId: action.data,
fetchingTxos: true,
fetchingTxosError: undefined,
};
},
[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 {
...state,
txoPage: action.data,
txoPage: action.data.result,
fetchId: '',
fetchingTxos: false,
};
},
@ -149,6 +159,7 @@ export const walletReducer = handleActions(
return {
...state,
txoPage: {},
fetchId: '',
fetchingTxos: false,
fetchingTxosError: action.data,
};