add doDeletePurchasedUri action

This commit is contained in:
Akinwale Ariwodola 2019-05-24 14:13:21 +01:00
parent 5cff70a26b
commit 071bfe9eac
7 changed files with 63 additions and 3 deletions

22
dist/bundle.es.js vendored
View file

@ -119,6 +119,7 @@ const SET_FILE_LIST_SORT = 'SET_FILE_LIST_SORT';
const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED'; const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED';
const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED'; const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED';
const PURCHASE_URI_FAILED = 'PURCHASE_URI_FAILED'; const PURCHASE_URI_FAILED = 'PURCHASE_URI_FAILED';
const DELETE_PURCHASED_URI = 'DELETE_PURCHASED_URI';
const LOADING_FILE_STARTED = 'LOADING_FILE_STARTED'; const LOADING_FILE_STARTED = 'LOADING_FILE_STARTED';
const LOADING_FILE_COMPLETED = 'LOADING_FILE_COMPLETED'; const LOADING_FILE_COMPLETED = 'LOADING_FILE_COMPLETED';
const LOADING_FILE_FAILED = 'LOADING_FILE_FAILED'; const LOADING_FILE_FAILED = 'LOADING_FILE_FAILED';
@ -341,6 +342,7 @@ var action_types = /*#__PURE__*/Object.freeze({
PURCHASE_URI_STARTED: PURCHASE_URI_STARTED, PURCHASE_URI_STARTED: PURCHASE_URI_STARTED,
PURCHASE_URI_COMPLETED: PURCHASE_URI_COMPLETED, PURCHASE_URI_COMPLETED: PURCHASE_URI_COMPLETED,
PURCHASE_URI_FAILED: PURCHASE_URI_FAILED, PURCHASE_URI_FAILED: PURCHASE_URI_FAILED,
DELETE_PURCHASED_URI: DELETE_PURCHASED_URI,
LOADING_FILE_STARTED: LOADING_FILE_STARTED, LOADING_FILE_STARTED: LOADING_FILE_STARTED,
LOADING_FILE_COMPLETED: LOADING_FILE_COMPLETED, LOADING_FILE_COMPLETED: LOADING_FILE_COMPLETED,
LOADING_FILE_FAILED: LOADING_FILE_FAILED, LOADING_FILE_FAILED: LOADING_FILE_FAILED,
@ -2417,6 +2419,13 @@ function doPurchaseUri(uri, costInfo, saveFile = true) {
}; };
} }
function doDeletePurchasedUri(uri) {
return {
type: DELETE_PURCHASED_URI,
data: { uri }
};
}
function doFetchFileInfo(uri) { function doFetchFileInfo(uri) {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
@ -2964,6 +2973,18 @@ reducers$1[PURCHASE_URI_FAILED] = (state, action) => {
}); });
}; };
reducers$1[DELETE_PURCHASED_URI] = (state, action) => {
const { uri } = action.data;
const newPurchasedUris = state.purchasedUris.slice();
if (newPurchasedUris.includes(uri)) {
newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1);
}
return _extends$4({}, state, {
purchasedUris: newPurchasedUris
});
};
function fileReducer(state = defaultState$1, action) { function fileReducer(state = defaultState$1, action) {
const handler = reducers$1[action.type]; const handler = reducers$1[action.type];
if (handler) return handler(state, action); if (handler) return handler(state, action);
@ -3663,6 +3684,7 @@ exports.doBalanceSubscribe = doBalanceSubscribe;
exports.doBlurSearchInput = doBlurSearchInput; exports.doBlurSearchInput = doBlurSearchInput;
exports.doCheckAddressIsMine = doCheckAddressIsMine; exports.doCheckAddressIsMine = doCheckAddressIsMine;
exports.doCreateChannel = doCreateChannel; exports.doCreateChannel = doCreateChannel;
exports.doDeletePurchasedUri = doDeletePurchasedUri;
exports.doDismissError = doDismissError; exports.doDismissError = doDismissError;
exports.doDismissToast = doDismissToast; exports.doDismissToast = doDismissToast;
exports.doError = doError; exports.doError = doError;

View file

@ -63,3 +63,10 @@ declare type PurchaseUriStarted = {
streamingUrl: string, streamingUrl: string,
}, },
}; };
declare type DeletePurchasedUri = {
type: ACTIONS.DELETE_PURCHASED_URI,
data: {
uri: string
},
};

7
flow-typed/File.js vendored
View file

@ -63,3 +63,10 @@ declare type PurchaseUriStarted = {
streamingUrl: string, streamingUrl: string,
}, },
}; };
declare type DeletePurchasedUri = {
type: ACTIONS.DELETE_PURCHASED_URI,
data: {
uri: string
},
};

View file

@ -109,6 +109,7 @@ export const SET_FILE_LIST_SORT = 'SET_FILE_LIST_SORT';
export const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED'; export const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED';
export const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED'; export const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED';
export const PURCHASE_URI_FAILED = 'PURCHASE_URI_FAILED'; export const PURCHASE_URI_FAILED = 'PURCHASE_URI_FAILED';
export const DELETE_PURCHASED_URI = 'DELETE_PURCHASED_URI';
export const LOADING_FILE_STARTED = 'LOADING_FILE_STARTED'; export const LOADING_FILE_STARTED = 'LOADING_FILE_STARTED';
export const LOADING_FILE_COMPLETED = 'LOADING_FILE_COMPLETED'; export const LOADING_FILE_COMPLETED = 'LOADING_FILE_COMPLETED';
export const LOADING_FILE_FAILED = 'LOADING_FILE_FAILED'; export const LOADING_FILE_FAILED = 'LOADING_FILE_FAILED';

View file

@ -47,7 +47,7 @@ export {
doCreateChannel, doCreateChannel,
} from 'redux/actions/claims'; } from 'redux/actions/claims';
export { doPurchaseUri, doFileGet } from 'redux/actions/file'; export { doDeletePurchasedUri, doPurchaseUri, doFileGet } from 'redux/actions/file';
export { export {
doFetchFileInfo, doFetchFileInfo,

View file

@ -102,3 +102,10 @@ export function doPurchaseUri(uri: string, costInfo: { cost: number }, saveFile:
dispatch(doFileGet(uri, saveFile)); dispatch(doFileGet(uri, saveFile));
}; };
} }
export function doDeletePurchasedUri(uri: string) {
return {
type: ACTIONS.DELETE_PURCHASED_URI,
data: { uri },
};
}

View file

@ -67,6 +67,22 @@ reducers[ACTIONS.PURCHASE_URI_FAILED] = (
}; };
}; };
reducers[ACTIONS.DELETE_PURCHASED_URI] = (
state: FileState,
action: DeletePurchasedUri
): FileState => {
const { uri } = action.data;
const newPurchasedUris = state.purchasedUris.slice();
if (newPurchasedUris.includes(uri)) {
newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1);
}
return {
...state,
purchasedUris: newPurchasedUris,
};
};
export function fileReducer(state: FileState = defaultState, action: any) { export function fileReducer(state: FileState = defaultState, action: any) {
const handler = reducers[action.type]; const handler = reducers[action.type];
if (handler) return handler(state, action); if (handler) return handler(state, action);