add purhcaseUriErrorMessage and more failure handling
This commit is contained in:
parent
95cc2bb14d
commit
152065b6c9
7 changed files with 30 additions and 11 deletions
21
dist/bundle.es.js
vendored
21
dist/bundle.es.js
vendored
|
@ -2321,6 +2321,8 @@ const selectFileListDownloadedSort = reselect.createSelector(selectState$3, stat
|
|||
|
||||
const selectState$4 = state => state.file || {};
|
||||
|
||||
const selectPurchaseUriErrorMessage = reselect.createSelector(selectState$4, state => state.purchaseUriErrorMessage);
|
||||
|
||||
const selectFailedPurchaseUris = reselect.createSelector(selectState$4, state => state.failedPurchaseUris);
|
||||
|
||||
const selectPurchasedUris = reselect.createSelector(selectState$4, state => state.purchasedUris);
|
||||
|
@ -2406,8 +2408,7 @@ function doPurchaseUri(uri, costInfo, saveFile = true) {
|
|||
}
|
||||
|
||||
const { cost } = costInfo;
|
||||
|
||||
if (cost > balance) {
|
||||
if (parseFloat(cost) > balance) {
|
||||
dispatch({
|
||||
type: PURCHASE_URI_FAILED,
|
||||
data: { uri, error: 'Insufficient credits' }
|
||||
|
@ -2923,7 +2924,8 @@ const reducers$1 = {};
|
|||
const defaultState$1 = {
|
||||
failedPurchaseUris: [],
|
||||
purchasedUris: [],
|
||||
purchasedStreamingUrls: {}
|
||||
purchasedStreamingUrls: {},
|
||||
purchaseUriErrorMessage: ''
|
||||
};
|
||||
|
||||
reducers$1[PURCHASE_URI_STARTED] = (state, action) => {
|
||||
|
@ -2934,7 +2936,8 @@ reducers$1[PURCHASE_URI_STARTED] = (state, action) => {
|
|||
}
|
||||
|
||||
return _extends$4({}, state, {
|
||||
failedPurchaseUris: newFailedPurchaseUris
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchaseUriErrorMessage: ''
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -2957,19 +2960,22 @@ reducers$1[PURCHASE_URI_COMPLETED] = (state, action) => {
|
|||
return _extends$4({}, state, {
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchasedUris: newPurchasedUris,
|
||||
purchasedStreamingUrls: newPurchasedStreamingUrls
|
||||
purchasedStreamingUrls: newPurchasedStreamingUrls,
|
||||
purchaseUriErrorMessage: ''
|
||||
});
|
||||
};
|
||||
|
||||
reducers$1[PURCHASE_URI_FAILED] = (state, action) => {
|
||||
const { uri } = action.data;
|
||||
const { uri, error } = action.data;
|
||||
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
|
||||
|
||||
if (!newFailedPurchaseUris.includes(uri)) {
|
||||
newFailedPurchaseUris.push(uri);
|
||||
}
|
||||
|
||||
return _extends$4({}, state, {
|
||||
failedPurchaseUris: newFailedPurchaseUris
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchaseUriErrorMessage: error
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -3806,6 +3812,7 @@ exports.selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels;
|
|||
exports.selectPendingById = selectPendingById;
|
||||
exports.selectPendingClaims = selectPendingClaims;
|
||||
exports.selectPlayingUri = selectPlayingUri;
|
||||
exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage;
|
||||
exports.selectPurchasedStreamingUrls = selectPurchasedStreamingUrls;
|
||||
exports.selectPurchasedUris = selectPurchasedUris;
|
||||
exports.selectReceiveAddress = selectReceiveAddress;
|
||||
|
|
3
dist/flow-typed/File.js
vendored
3
dist/flow-typed/File.js
vendored
|
@ -52,7 +52,8 @@ declare type PurchaseUriCompleted = {
|
|||
declare type PurchaseUriFailed = {
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: {
|
||||
uri: string
|
||||
uri: string,
|
||||
error: any
|
||||
},
|
||||
};
|
||||
|
||||
|
|
3
flow-typed/File.js
vendored
3
flow-typed/File.js
vendored
|
@ -52,7 +52,8 @@ declare type PurchaseUriCompleted = {
|
|||
declare type PurchaseUriFailed = {
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: {
|
||||
uri: string
|
||||
uri: string,
|
||||
error: any
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ export {
|
|||
selectFailedPurchaseUris,
|
||||
selectPurchasedUris,
|
||||
selectPurchasedStreamingUrls,
|
||||
selectPurchaseUriErrorMessage,
|
||||
selectLastPurchasedUri,
|
||||
makeSelectStreamingUrlForUri,
|
||||
} from 'redux/selectors/file';
|
||||
|
|
|
@ -88,7 +88,6 @@ export function doPurchaseUri(uri: string, costInfo: { cost: number }, saveFile:
|
|||
}
|
||||
|
||||
const { cost } = costInfo;
|
||||
|
||||
if (parseFloat(cost) > balance) {
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
|
|
|
@ -6,6 +6,7 @@ const defaultState = {
|
|||
failedPurchaseUris: [],
|
||||
purchasedUris: [],
|
||||
purchasedStreamingUrls: {},
|
||||
purchaseUriErrorMessage: '',
|
||||
};
|
||||
|
||||
reducers[ACTIONS.PURCHASE_URI_STARTED] = (
|
||||
|
@ -21,6 +22,7 @@ reducers[ACTIONS.PURCHASE_URI_STARTED] = (
|
|||
return {
|
||||
...state,
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchaseUriErrorMessage: '',
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -48,6 +50,7 @@ reducers[ACTIONS.PURCHASE_URI_COMPLETED] = (
|
|||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchasedUris: newPurchasedUris,
|
||||
purchasedStreamingUrls: newPurchasedStreamingUrls,
|
||||
purchaseUriErrorMessage: '',
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -55,8 +58,9 @@ reducers[ACTIONS.PURCHASE_URI_FAILED] = (
|
|||
state: FileState,
|
||||
action: PurchaseUriFailed
|
||||
): FileState => {
|
||||
const { uri } = action.data;
|
||||
const { uri, error } = action.data;
|
||||
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
|
||||
|
||||
if (!newFailedPurchaseUris.includes(uri)) {
|
||||
newFailedPurchaseUris.push(uri);
|
||||
}
|
||||
|
@ -64,6 +68,7 @@ reducers[ACTIONS.PURCHASE_URI_FAILED] = (
|
|||
return {
|
||||
...state,
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchaseUriErrorMessage: error,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@ type State = { file: FileState };
|
|||
|
||||
export const selectState = (state: State): FileState => state.file || {};
|
||||
|
||||
export const selectPurchaseUriErrorMessage: (state: State) => string = createSelector(
|
||||
selectState,
|
||||
state => state.purchaseUriErrorMessage
|
||||
);
|
||||
|
||||
export const selectFailedPurchaseUris: (state: State) => Array<string> = createSelector(
|
||||
selectState,
|
||||
state => state.failedPurchaseUris
|
||||
|
|
Loading…
Add table
Reference in a new issue