remove the uri from the failed list if the user reattempts getting the same uri #151

Merged
akinwale merged 5 commits from purchase-uri-failures into master 2019-05-27 15:59:21 +02:00
2 changed files with 24 additions and 0 deletions
Showing only changes of commit a5d486bd3b - Show all commits

8
flow-typed/File.js vendored
View file

@ -55,3 +55,11 @@ declare type PurchaseUriFailed = {
uri: string
},
};
declare type PurchaseUriStarted = {
type: ACTIONS.PURCHASE_URI_STARTED,
data: {
uri: string,
streamingUrl: string,
},
};

View file

@ -8,6 +8,22 @@ const defaultState = {
purchasedStreamingUrls: {},
};
reducers[ACTIONS.PURCHASE_URI_STARTED] = (
state: FileState,
action: PurchaseUriStarted
): FileState => {
const { uri } = action.data;
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
if (newFailedPurchaseUris.includes(uri)) {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
}
return {
...state,
failedPurchaseUris: newFailedPurchaseUris,
};
};
reducers[ACTIONS.PURCHASE_URI_COMPLETED] = (
state: FileState,
action: PurchaseUriCompleted