remove purchasedStreamingUrls
This commit is contained in:
parent
faf4402309
commit
fe66fae040
11 changed files with 26 additions and 63 deletions
36
dist/bundle.es.js
vendored
36
dist/bundle.es.js
vendored
|
@ -153,9 +153,6 @@ const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED';
|
|||
const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED';
|
||||
const PURCHASE_URI_FAILED = 'PURCHASE_URI_FAILED';
|
||||
const DELETE_PURCHASED_URI = 'DELETE_PURCHASED_URI';
|
||||
const LOADING_FILE_STARTED = 'LOADING_FILE_STARTED';
|
||||
const LOADING_FILE_COMPLETED = 'LOADING_FILE_COMPLETED';
|
||||
const LOADING_FILE_FAILED = 'LOADING_FILE_FAILED';
|
||||
|
||||
// Search
|
||||
const SEARCH_START = 'SEARCH_START';
|
||||
|
@ -382,9 +379,6 @@ var action_types = /*#__PURE__*/Object.freeze({
|
|||
PURCHASE_URI_COMPLETED: PURCHASE_URI_COMPLETED,
|
||||
PURCHASE_URI_FAILED: PURCHASE_URI_FAILED,
|
||||
DELETE_PURCHASED_URI: DELETE_PURCHASED_URI,
|
||||
LOADING_FILE_STARTED: LOADING_FILE_STARTED,
|
||||
LOADING_FILE_COMPLETED: LOADING_FILE_COMPLETED,
|
||||
LOADING_FILE_FAILED: LOADING_FILE_FAILED,
|
||||
SEARCH_START: SEARCH_START,
|
||||
SEARCH_SUCCESS: SEARCH_SUCCESS,
|
||||
SEARCH_FAIL: SEARCH_FAIL,
|
||||
|
@ -717,8 +711,10 @@ const Lbry = {
|
|||
|
||||
// Get mediaType from contentType
|
||||
if (contentType) {
|
||||
return (/^[^/]+/.exec(contentType)[0]
|
||||
);
|
||||
const matches = /^[^/]+/.exec(contentType);
|
||||
if (matches) {
|
||||
return matches[0];
|
||||
}
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
|
@ -2625,8 +2621,6 @@ const selectFailedPurchaseUris = reselect.createSelector(selectState$4, state =>
|
|||
|
||||
const selectPurchasedUris = reselect.createSelector(selectState$4, state => state.purchasedUris);
|
||||
|
||||
const selectPurchasedStreamingUrls = reselect.createSelector(selectState$4, state => state.purchasedStreamingUrls);
|
||||
|
||||
const selectLastPurchasedUri = reselect.createSelector(selectState$4, state => state.purchasedUris.length > 0 ? state.purchasedUris[state.purchasedUris.length - 1] : null);
|
||||
|
||||
const makeSelectStreamingUrlForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), fileInfo => {
|
||||
|
@ -2638,7 +2632,7 @@ const makeSelectStreamingUrlForUri = uri => reselect.createSelector(makeSelectFi
|
|||
function doFileGet(uri, saveFile = true, onSuccess) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: LOADING_FILE_STARTED,
|
||||
type: PURCHASE_URI_STARTED,
|
||||
data: {
|
||||
uri
|
||||
}
|
||||
|
@ -2649,10 +2643,6 @@ function doFileGet(uri, saveFile = true, onSuccess) {
|
|||
const timeout = streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout';
|
||||
|
||||
if (timeout) {
|
||||
dispatch({
|
||||
type: LOADING_FILE_FAILED,
|
||||
data: { uri }
|
||||
});
|
||||
dispatch({
|
||||
type: PURCHASE_URI_FAILED,
|
||||
data: { uri }
|
||||
|
@ -2661,10 +2651,9 @@ function doFileGet(uri, saveFile = true, onSuccess) {
|
|||
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
|
||||
} else {
|
||||
// purchase was completed successfully
|
||||
const { streaming_url: streamingUrl } = streamInfo;
|
||||
dispatch({
|
||||
type: PURCHASE_URI_COMPLETED,
|
||||
data: { uri, streamingUrl }
|
||||
data: { uri }
|
||||
});
|
||||
dispatch({
|
||||
type: FETCH_FILE_INFO_COMPLETED,
|
||||
|
@ -2679,10 +2668,6 @@ function doFileGet(uri, saveFile = true, onSuccess) {
|
|||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
dispatch({
|
||||
type: LOADING_FILE_FAILED,
|
||||
data: { uri }
|
||||
});
|
||||
dispatch({
|
||||
type: PURCHASE_URI_FAILED,
|
||||
data: { uri }
|
||||
|
@ -4060,7 +4045,6 @@ const reducers$3 = {};
|
|||
const defaultState$4 = {
|
||||
failedPurchaseUris: [],
|
||||
purchasedUris: [],
|
||||
purchasedStreamingUrls: {},
|
||||
purchaseUriErrorMessage: ''
|
||||
};
|
||||
|
||||
|
@ -4078,10 +4062,9 @@ reducers$3[PURCHASE_URI_STARTED] = (state, action) => {
|
|||
};
|
||||
|
||||
reducers$3[PURCHASE_URI_COMPLETED] = (state, action) => {
|
||||
const { uri, streamingUrl } = action.data;
|
||||
const { uri } = action.data;
|
||||
const newPurchasedUris = state.purchasedUris.slice();
|
||||
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
|
||||
const newPurchasedStreamingUrls = Object.assign({}, state.purchasedStreamingUrls);
|
||||
|
||||
if (!newPurchasedUris.includes(uri)) {
|
||||
newPurchasedUris.push(uri);
|
||||
|
@ -4089,14 +4072,10 @@ reducers$3[PURCHASE_URI_COMPLETED] = (state, action) => {
|
|||
if (newFailedPurchaseUris.includes(uri)) {
|
||||
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
|
||||
}
|
||||
if (streamingUrl) {
|
||||
newPurchasedStreamingUrls[uri] = streamingUrl;
|
||||
}
|
||||
|
||||
return _extends$9({}, state, {
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchasedUris: newPurchasedUris,
|
||||
purchasedStreamingUrls: newPurchasedStreamingUrls,
|
||||
purchaseUriErrorMessage: ''
|
||||
});
|
||||
};
|
||||
|
@ -4976,7 +4955,6 @@ exports.selectPendingClaims = selectPendingClaims;
|
|||
exports.selectPlayingUri = selectPlayingUri;
|
||||
exports.selectPublishFormValues = selectPublishFormValues;
|
||||
exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage;
|
||||
exports.selectPurchasedStreamingUrls = selectPurchasedStreamingUrls;
|
||||
exports.selectPurchasedUris = selectPurchasedUris;
|
||||
exports.selectReceiveAddress = selectReceiveAddress;
|
||||
exports.selectRecentTransactions = selectRecentTransactions;
|
||||
|
|
5
dist/flow-typed/File.js
vendored
5
dist/flow-typed/File.js
vendored
|
@ -38,7 +38,6 @@ declare type FileListItem = {
|
|||
declare type FileState = {
|
||||
failedPurchaseUris: Array<string>,
|
||||
purchasedUris: Array<string>,
|
||||
purchasedStreamingUrls: {},
|
||||
};
|
||||
|
||||
declare type PurchaseUriCompleted = {
|
||||
|
@ -53,7 +52,7 @@ declare type PurchaseUriFailed = {
|
|||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: {
|
||||
uri: string,
|
||||
error: any
|
||||
error: any,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -68,6 +67,6 @@ declare type PurchaseUriStarted = {
|
|||
declare type DeletePurchasedUri = {
|
||||
type: ACTIONS.DELETE_PURCHASED_URI,
|
||||
data: {
|
||||
uri: string
|
||||
uri: string,
|
||||
},
|
||||
};
|
||||
|
|
4
dist/flow-typed/mime.js
vendored
Normal file
4
dist/flow-typed/mime.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// @flow
|
||||
declare module 'mime' {
|
||||
declare module.exports: any;
|
||||
}
|
5
flow-typed/File.js
vendored
5
flow-typed/File.js
vendored
|
@ -38,7 +38,6 @@ declare type FileListItem = {
|
|||
declare type FileState = {
|
||||
failedPurchaseUris: Array<string>,
|
||||
purchasedUris: Array<string>,
|
||||
purchasedStreamingUrls: {},
|
||||
};
|
||||
|
||||
declare type PurchaseUriCompleted = {
|
||||
|
@ -53,7 +52,7 @@ declare type PurchaseUriFailed = {
|
|||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: {
|
||||
uri: string,
|
||||
error: any
|
||||
error: any,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -68,6 +67,6 @@ declare type PurchaseUriStarted = {
|
|||
declare type DeletePurchasedUri = {
|
||||
type: ACTIONS.DELETE_PURCHASED_URI,
|
||||
data: {
|
||||
uri: string
|
||||
uri: string,
|
||||
},
|
||||
};
|
||||
|
|
4
flow-typed/mime.js
vendored
Normal file
4
flow-typed/mime.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// @flow
|
||||
declare module 'mime' {
|
||||
declare module.exports: any;
|
||||
}
|
|
@ -127,9 +127,6 @@ export const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED';
|
|||
export const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED';
|
||||
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_COMPLETED = 'LOADING_FILE_COMPLETED';
|
||||
export const LOADING_FILE_FAILED = 'LOADING_FILE_FAILED';
|
||||
|
||||
// Search
|
||||
export const SEARCH_START = 'SEARCH_START';
|
||||
|
|
|
@ -140,7 +140,6 @@ export { selectToast, selectError } from 'redux/selectors/notifications';
|
|||
export {
|
||||
selectFailedPurchaseUris,
|
||||
selectPurchasedUris,
|
||||
selectPurchasedStreamingUrls,
|
||||
selectPurchaseUriErrorMessage,
|
||||
selectLastPurchasedUri,
|
||||
makeSelectStreamingUrlForUri,
|
||||
|
|
|
@ -61,7 +61,10 @@ const Lbry: LbryTypes = {
|
|||
|
||||
// Get mediaType from contentType
|
||||
if (contentType) {
|
||||
return /^[^/]+/.exec(contentType)[0];
|
||||
const matches = /^[^/]+/.exec(contentType);
|
||||
if (matches) {
|
||||
return matches[0];
|
||||
}
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
|
|
|
@ -12,7 +12,7 @@ type GetState = () => { file: FileState };
|
|||
export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: GetResponse => any) {
|
||||
return (dispatch: Dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.LOADING_FILE_STARTED,
|
||||
type: ACTIONS.PURCHASE_URI_STARTED,
|
||||
data: {
|
||||
uri,
|
||||
},
|
||||
|
@ -25,10 +25,6 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
|
|||
streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout';
|
||||
|
||||
if (timeout) {
|
||||
dispatch({
|
||||
type: ACTIONS.LOADING_FILE_FAILED,
|
||||
data: { uri },
|
||||
});
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: { uri },
|
||||
|
@ -37,10 +33,9 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
|
|||
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
|
||||
} else {
|
||||
// purchase was completed successfully
|
||||
const { streaming_url: streamingUrl } = streamInfo;
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_COMPLETED,
|
||||
data: { uri, streamingUrl },
|
||||
data: { uri },
|
||||
});
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_FILE_INFO_COMPLETED,
|
||||
|
@ -56,10 +51,6 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
|
|||
}
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch({
|
||||
type: ACTIONS.LOADING_FILE_FAILED,
|
||||
data: { uri },
|
||||
});
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: { uri },
|
||||
|
|
|
@ -5,7 +5,6 @@ const reducers = {};
|
|||
const defaultState = {
|
||||
failedPurchaseUris: [],
|
||||
purchasedUris: [],
|
||||
purchasedStreamingUrls: {},
|
||||
purchaseUriErrorMessage: '',
|
||||
};
|
||||
|
||||
|
@ -30,10 +29,9 @@ reducers[ACTIONS.PURCHASE_URI_COMPLETED] = (
|
|||
state: FileState,
|
||||
action: PurchaseUriCompleted
|
||||
): FileState => {
|
||||
const { uri, streamingUrl } = action.data;
|
||||
const { uri } = action.data;
|
||||
const newPurchasedUris = state.purchasedUris.slice();
|
||||
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
|
||||
const newPurchasedStreamingUrls = Object.assign({}, state.purchasedStreamingUrls);
|
||||
|
||||
if (!newPurchasedUris.includes(uri)) {
|
||||
newPurchasedUris.push(uri);
|
||||
|
@ -41,15 +39,11 @@ reducers[ACTIONS.PURCHASE_URI_COMPLETED] = (
|
|||
if (newFailedPurchaseUris.includes(uri)) {
|
||||
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
|
||||
}
|
||||
if (streamingUrl) {
|
||||
newPurchasedStreamingUrls[uri] = streamingUrl;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
failedPurchaseUris: newFailedPurchaseUris,
|
||||
purchasedUris: newPurchasedUris,
|
||||
purchasedStreamingUrls: newPurchasedStreamingUrls,
|
||||
purchaseUriErrorMessage: '',
|
||||
};
|
||||
};
|
||||
|
|
|
@ -21,11 +21,6 @@ export const selectPurchasedUris: (state: State) => Array<string> = createSelect
|
|||
state => state.purchasedUris
|
||||
);
|
||||
|
||||
export const selectPurchasedStreamingUrls: (state: State) => {} = createSelector(
|
||||
selectState,
|
||||
state => state.purchasedStreamingUrls
|
||||
);
|
||||
|
||||
export const selectLastPurchasedUri: (state: State) => string = createSelector(
|
||||
selectState,
|
||||
state =>
|
||||
|
|
Loading…
Add table
Reference in a new issue