paid file changes for lbry.tv

This commit is contained in:
Sean Yesmunt 2020-05-18 16:40:33 -04:00
parent 486e24621e
commit f660f1070c
10 changed files with 235 additions and 372 deletions

384
dist/bundle.es.js vendored
View file

@ -2300,6 +2300,8 @@ const makeSelectClaimIsMine = rawUri => {
const selectMyPurchases = reselect.createSelector(selectState$2, state => state.myPurchases); const selectMyPurchases = reselect.createSelector(selectState$2, state => state.myPurchases);
const selectPurchaseUriSuccess = reselect.createSelector(selectState$2, state => state.purchaseUriSuccess);
const selectMyPurchasesCount = reselect.createSelector(selectState$2, state => state.myPurchasesPageTotalResults); const selectMyPurchasesCount = reselect.createSelector(selectState$2, state => state.myPurchasesPageTotalResults);
const selectIsFetchingMyPurchases = reselect.createSelector(selectState$2, state => state.fetchingMyPurchases); const selectIsFetchingMyPurchases = reselect.createSelector(selectState$2, state => state.fetchingMyPurchases);
@ -3926,18 +3928,6 @@ const makeSelectSearchDownloadUrlsCount = query => reselect.createSelector(selec
return fileInfos && fileInfos.length ? filterFileInfos(fileInfos, query).length : 0; return fileInfos && fileInfos.length ? filterFileInfos(fileInfos, query).length : 0;
}); });
//
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);
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 => { const makeSelectStreamingUrlForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), fileInfo => {
return fileInfo && fileInfo.streaming_url; return fileInfo && fileInfo.streaming_url;
}); });
@ -3960,7 +3950,6 @@ function doFileGet(uri, saveFile = true, onSuccess) {
// set save_file argument to True to save the file (old behaviour) // set save_file argument to True to save the file (old behaviour)
lbryProxy.get({ uri, save_file: saveFile }).then(streamInfo => { lbryProxy.get({ uri, save_file: saveFile }).then(streamInfo => {
const timeout = streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout'; const timeout = streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout';
if (timeout) { if (timeout) {
dispatch({ dispatch({
type: FETCH_FILE_INFO_FAILED, type: FETCH_FILE_INFO_FAILED,
@ -3969,11 +3958,12 @@ function doFileGet(uri, saveFile = true, onSuccess) {
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true })); dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
} else { } else {
// purchase was completed successfully if (streamInfo.content_fee) {
dispatch({ dispatch({
type: PURCHASE_URI_COMPLETED, type: PURCHASE_URI_COMPLETED,
data: { uri } data: { uri, purchaseReceipt: streamInfo.content_fee }
}); });
}
dispatch({ dispatch({
type: FETCH_FILE_INFO_COMPLETED, type: FETCH_FILE_INFO_COMPLETED,
data: { data: {
@ -3986,10 +3976,10 @@ function doFileGet(uri, saveFile = true, onSuccess) {
onSuccess(streamInfo); onSuccess(streamInfo);
} }
} }
}).catch(() => { }).catch(error => {
dispatch({ dispatch({
type: PURCHASE_URI_FAILED, type: PURCHASE_URI_FAILED,
data: { uri } data: { uri, error }
}); });
dispatch({ dispatch({
@ -4120,10 +4110,10 @@ var _extends$6 = Object.assign || function (target) { for (var i = 1; i < argume
function _objectWithoutProperties$2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _objectWithoutProperties$2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
const selectState$5 = state => state.publish || {}; const selectState$4 = state => state.publish || {};
// Is the current uri the same as the uri they clicked "edit" on // Is the current uri the same as the uri they clicked "edit" on
const selectIsStillEditing = reselect.createSelector(selectState$5, publishState => { const selectIsStillEditing = reselect.createSelector(selectState$4, publishState => {
const { editingURI, uri } = publishState; const { editingURI, uri } = publishState;
if (!editingURI || !uri) { if (!editingURI || !uri) {
@ -4148,7 +4138,7 @@ const selectIsStillEditing = reselect.createSelector(selectState$5, publishState
return currentName === editName; return currentName === editName;
}); });
const selectPublishFormValues = reselect.createSelector(selectState$5, selectIsStillEditing, (state, isStillEditing) => { const selectPublishFormValues = reselect.createSelector(selectState$4, selectIsStillEditing, (state, isStillEditing) => {
const { pendingPublish, language, languages } = state, const { pendingPublish, language, languages } = state,
formValues = _objectWithoutProperties$2(state, ['pendingPublish', 'language', 'languages']); formValues = _objectWithoutProperties$2(state, ['pendingPublish', 'language', 'languages']);
@ -4161,7 +4151,7 @@ const selectPublishFormValues = reselect.createSelector(selectState$5, selectIsS
} }
return _extends$6({}, formValues, { language: actualLanguage }); return _extends$6({}, formValues, { language: actualLanguage });
}); });
const makeSelectPublishFormValue = item => reselect.createSelector(selectState$5, state => state[item]); const makeSelectPublishFormValue = item => reselect.createSelector(selectState$4, state => state[item]);
const selectMyClaimForUri = reselect.createSelector(selectPublishFormValues, selectIsStillEditing, selectClaimsById, selectMyClaimsWithoutChannels, ({ editingURI, uri }, isStillEditing, claimsById, myClaims) => { const selectMyClaimForUri = reselect.createSelector(selectPublishFormValues, selectIsStillEditing, selectClaimsById, selectMyClaimsWithoutChannels, ({ editingURI, uri }, isStillEditing, claimsById, myClaims) => {
const { channelName: contentName, streamName: claimName } = parseURI(uri); const { channelName: contentName, streamName: claimName } = parseURI(uri);
@ -4174,7 +4164,7 @@ const selectMyClaimForUri = reselect.createSelector(selectPublishFormValues, sel
return isStillEditing ? claimsById[editClaimId] : myClaims.find(claim => !contentName ? claim.name === claimName : claim.name === contentName || claim.name === claimName); return isStillEditing ? claimsById[editClaimId] : myClaims.find(claim => !contentName ? claim.name === claimName : claim.name === contentName || claim.name === claimName);
}); });
const selectIsResolvingPublishUris = reselect.createSelector(selectState$5, selectResolvingUris, ({ uri, name }, resolvingUris) => { const selectIsResolvingPublishUris = reselect.createSelector(selectState$4, selectResolvingUris, ({ uri, name }, resolvingUris) => {
if (uri) { if (uri) {
const isResolvingUri = resolvingUris.includes(uri); const isResolvingUri = resolvingUris.includes(uri);
const { isChannel } = parseURI(uri); const { isChannel } = parseURI(uri);
@ -4191,7 +4181,7 @@ const selectIsResolvingPublishUris = reselect.createSelector(selectState$5, sele
return false; return false;
}); });
const selectTakeOverAmount = reselect.createSelector(selectState$5, selectMyClaimForUri, selectClaimsByUri, ({ name }, myClaimForUri, claimsByUri) => { const selectTakeOverAmount = reselect.createSelector(selectState$4, selectMyClaimForUri, selectClaimsByUri, ({ name }, myClaimForUri, claimsByUri) => {
if (!name) { if (!name) {
return null; return null;
} }
@ -5119,6 +5109,7 @@ const defaultState = {
myPurchases: undefined, myPurchases: undefined,
myPurchasesPageNumber: undefined, myPurchasesPageNumber: undefined,
myPurchasesPageTotalResults: undefined, myPurchasesPageTotalResults: undefined,
purchaseUriSuccess: false,
fetchingMyPurchases: false, fetchingMyPurchases: false,
fetchingMyPurchasesError: undefined, fetchingMyPurchasesError: undefined,
fetchingMyChannels: false, fetchingMyChannels: false,
@ -5712,6 +5703,34 @@ reducers[PURCHASE_LIST_FAILED] = (state, action) => {
}); });
}; };
reducers[PURCHASE_URI_COMPLETED] = (state, action) => {
const { uri, purchaseReceipt } = action.data;
let byId = Object.assign({}, state.byId);
let byUri = Object.assign({}, state.claimsByUri);
let myPurchases = state.myPurchases ? state.myPurchases.slice() : [];
const claimId = byUri[uri];
if (claimId) {
let claim = byId[claimId];
claim.purchase_receipt = purchaseReceipt;
}
myPurchases.push(uri);
return _extends$9({}, state, {
byId,
myPurchases,
purchaseUriSuccess: true
});
};
reducers[PURCHASE_URI_FAILED] = state => {
return _extends$9({}, state, {
purchaseUriSuccess: false
});
};
function claimsReducer(state = defaultState, action) { function claimsReducer(state = defaultState, action) {
const handler = reducers[action.type]; const handler = reducers[action.type];
if (handler) return handler(state, action); if (handler) return handler(state, action);
@ -6051,80 +6070,7 @@ function fileInfoReducer(state = defaultState$3, action) {
var _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const reducers$3 = {};
const defaultState$4 = { const defaultState$4 = {
failedPurchaseUris: [],
purchasedUris: [],
purchaseUriErrorMessage: ''
};
reducers$3[PURCHASE_URI_STARTED] = (state, action) => {
const { uri } = action.data;
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
if (newFailedPurchaseUris.includes(uri)) {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
}
return _extends$c({}, state, {
failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: ''
});
};
reducers$3[PURCHASE_URI_COMPLETED] = (state, action) => {
const { uri } = action.data;
const newPurchasedUris = state.purchasedUris.slice();
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
if (!newPurchasedUris.includes(uri)) {
newPurchasedUris.push(uri);
}
if (newFailedPurchaseUris.includes(uri)) {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
}
return _extends$c({}, state, {
failedPurchaseUris: newFailedPurchaseUris,
purchasedUris: newPurchasedUris,
purchaseUriErrorMessage: ''
});
};
reducers$3[PURCHASE_URI_FAILED] = (state, action) => {
const { uri, error } = action.data;
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
if (!newFailedPurchaseUris.includes(uri)) {
newFailedPurchaseUris.push(uri);
}
return _extends$c({}, state, {
failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: error
});
};
reducers$3[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$c({}, state, {
purchasedUris: newPurchasedUris
});
};
function fileReducer(state = defaultState$4, action) {
const handler = reducers$3[action.type];
if (handler) return handler(state, action);
return state;
}
var _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const defaultState$5 = {
notifications: [], notifications: [],
toasts: [], toasts: [],
errors: [] errors: []
@ -6137,7 +6083,7 @@ const notificationsReducer = handleActions({
const newToasts = state.toasts.slice(); const newToasts = state.toasts.slice();
newToasts.push(toast); newToasts.push(toast);
return _extends$d({}, state, { return _extends$c({}, state, {
toasts: newToasts toasts: newToasts
}); });
}, },
@ -6145,7 +6091,7 @@ const notificationsReducer = handleActions({
const newToasts = state.toasts.slice(); const newToasts = state.toasts.slice();
newToasts.shift(); newToasts.shift();
return _extends$d({}, state, { return _extends$c({}, state, {
toasts: newToasts toasts: newToasts
}); });
}, },
@ -6156,7 +6102,7 @@ const notificationsReducer = handleActions({
const newNotifications = state.notifications.slice(); const newNotifications = state.notifications.slice();
newNotifications.push(notification); newNotifications.push(notification);
return _extends$d({}, state, { return _extends$c({}, state, {
notifications: newNotifications notifications: newNotifications
}); });
}, },
@ -6167,7 +6113,7 @@ const notificationsReducer = handleActions({
notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification); notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification);
return _extends$d({}, state, { return _extends$c({}, state, {
notifications notifications
}); });
}, },
@ -6176,7 +6122,7 @@ const notificationsReducer = handleActions({
let newNotifications = state.notifications.slice(); let newNotifications = state.notifications.slice();
newNotifications = newNotifications.filter(notification => notification.id !== id); newNotifications = newNotifications.filter(notification => notification.id !== id);
return _extends$d({}, state, { return _extends$c({}, state, {
notifications: newNotifications notifications: newNotifications
}); });
}, },
@ -6187,7 +6133,7 @@ const notificationsReducer = handleActions({
const newErrors = state.errors.slice(); const newErrors = state.errors.slice();
newErrors.push(error); newErrors.push(error);
return _extends$d({}, state, { return _extends$c({}, state, {
errors: newErrors errors: newErrors
}); });
}, },
@ -6195,17 +6141,17 @@ const notificationsReducer = handleActions({
const newErrors = state.errors.slice(); const newErrors = state.errors.slice();
newErrors.shift(); newErrors.shift();
return _extends$d({}, state, { return _extends$c({}, state, {
errors: newErrors errors: newErrors
}); });
} }
}, defaultState$5); }, defaultState$4);
var _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties$4(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _objectWithoutProperties$4(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
const defaultState$6 = { const defaultState$5 = {
editingURI: undefined, editingURI: undefined,
filePath: undefined, filePath: undefined,
fileDur: 0, fileDur: 0,
@ -6242,20 +6188,20 @@ const defaultState$6 = {
const publishReducer = handleActions({ const publishReducer = handleActions({
[UPDATE_PUBLISH_FORM]: (state, action) => { [UPDATE_PUBLISH_FORM]: (state, action) => {
const { data } = action; const { data } = action;
return _extends$e({}, state, data); return _extends$d({}, state, data);
}, },
[CLEAR_PUBLISH]: state => _extends$e({}, defaultState$6, { [CLEAR_PUBLISH]: state => _extends$d({}, defaultState$5, {
bid: state.bid, bid: state.bid,
optimize: state.optimize optimize: state.optimize
}), }),
[PUBLISH_START]: state => _extends$e({}, state, { [PUBLISH_START]: state => _extends$d({}, state, {
publishing: true, publishing: true,
publishSuccess: false publishSuccess: false
}), }),
[PUBLISH_FAIL]: state => _extends$e({}, state, { [PUBLISH_FAIL]: state => _extends$d({}, state, {
publishing: false publishing: false
}), }),
[PUBLISH_SUCCESS]: state => _extends$e({}, state, { [PUBLISH_SUCCESS]: state => _extends$d({}, state, {
publishing: false, publishing: false,
publishSuccess: true publishSuccess: true
}), }),
@ -6270,16 +6216,16 @@ const publishReducer = handleActions({
streamName: name streamName: name
}); });
return _extends$e({}, defaultState$6, publishData, { return _extends$d({}, defaultState$5, publishData, {
editingURI: uri, editingURI: uri,
uri: shortUri uri: shortUri
}); });
} }
}, defaultState$6); }, defaultState$5);
var _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const defaultState$7 = { const defaultState$6 = {
isActive: false, // does the user have any typed text in the search input isActive: false, // does the user have any typed text in the search input
focused: false, // is the search input focused focused: false, // is the search input focused
searchQuery: '', // needs to be an empty string for input focusing searchQuery: '', // needs to be an empty string for input focusing
@ -6299,23 +6245,23 @@ const defaultState$7 = {
}; };
const searchReducer = handleActions({ const searchReducer = handleActions({
[SEARCH_START]: state => _extends$f({}, state, { [SEARCH_START]: state => _extends$e({}, state, {
searching: true searching: true
}), }),
[SEARCH_SUCCESS]: (state, action) => { [SEARCH_SUCCESS]: (state, action) => {
const { query, uris } = action.data; const { query, uris } = action.data;
return _extends$f({}, state, { return _extends$e({}, state, {
searching: false, searching: false,
urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris }) urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris })
}); });
}, },
[SEARCH_FAIL]: state => _extends$f({}, state, { [SEARCH_FAIL]: state => _extends$e({}, state, {
searching: false searching: false
}), }),
[RESOLVED_SEARCH_START]: state => _extends$f({}, state, { [RESOLVED_SEARCH_START]: state => _extends$e({}, state, {
searching: true searching: true
}), }),
[RESOLVED_SEARCH_SUCCESS]: (state, action) => { [RESOLVED_SEARCH_SUCCESS]: (state, action) => {
@ -6333,24 +6279,24 @@ const searchReducer = handleActions({
// the returned number of urls is less than the page size, so we're on the last page // the returned number of urls is less than the page size, so we're on the last page
resolvedResultsByQueryLastPageReached[query] = results.length < pageSize; resolvedResultsByQueryLastPageReached[query] = results.length < pageSize;
return _extends$f({}, state, { return _extends$e({}, state, {
searching: false, searching: false,
resolvedResultsByQuery, resolvedResultsByQuery,
resolvedResultsByQueryLastPageReached resolvedResultsByQueryLastPageReached
}); });
}, },
[RESOLVED_SEARCH_FAIL]: state => _extends$f({}, state, { [RESOLVED_SEARCH_FAIL]: state => _extends$e({}, state, {
searching: false searching: false
}), }),
[UPDATE_SEARCH_QUERY]: (state, action) => _extends$f({}, state, { [UPDATE_SEARCH_QUERY]: (state, action) => _extends$e({}, state, {
searchQuery: action.data.query, searchQuery: action.data.query,
isActive: true isActive: true
}), }),
[UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$f({}, state, { [UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$e({}, state, {
suggestions: _extends$f({}, state.suggestions, { suggestions: _extends$e({}, state.suggestions, {
[action.data.query]: action.data.suggestions [action.data.query]: action.data.suggestions
}) })
}), }),
@ -6358,35 +6304,35 @@ const searchReducer = handleActions({
// sets isActive to false so the uri will be populated correctly if the // sets isActive to false so the uri will be populated correctly if the
// user is on a file page. The search query will still be present on any // user is on a file page. The search query will still be present on any
// other page // other page
[DISMISS_NOTIFICATION]: state => _extends$f({}, state, { [DISMISS_NOTIFICATION]: state => _extends$e({}, state, {
isActive: false isActive: false
}), }),
[SEARCH_FOCUS]: state => _extends$f({}, state, { [SEARCH_FOCUS]: state => _extends$e({}, state, {
focused: true focused: true
}), }),
[SEARCH_BLUR]: state => _extends$f({}, state, { [SEARCH_BLUR]: state => _extends$e({}, state, {
focused: false focused: false
}), }),
[UPDATE_SEARCH_OPTIONS]: (state, action) => { [UPDATE_SEARCH_OPTIONS]: (state, action) => {
const { options: oldOptions } = state; const { options: oldOptions } = state;
const newOptions = action.data; const newOptions = action.data;
const options = _extends$f({}, oldOptions, newOptions); const options = _extends$e({}, oldOptions, newOptions);
return _extends$f({}, state, { return _extends$e({}, state, {
options options
}); });
} }
}, defaultState$7); }, defaultState$6);
var _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function getDefaultKnownTags() { function getDefaultKnownTags() {
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => _extends$g({}, tagsMap, { return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => _extends$f({}, tagsMap, {
[tag]: { name: tag } [tag]: { name: tag }
}), {}); }), {});
} }
const defaultState$8 = { const defaultState$7 = {
followedTags: [], followedTags: [],
knownTags: getDefaultKnownTags() knownTags: getDefaultKnownTags()
}; };
@ -6404,7 +6350,7 @@ const tagsReducer = handleActions({
newFollowedTags.push(name); newFollowedTags.push(name);
} }
return _extends$g({}, state, { return _extends$f({}, state, {
followedTags: newFollowedTags followedTags: newFollowedTags
}); });
}, },
@ -6413,10 +6359,10 @@ const tagsReducer = handleActions({
const { knownTags } = state; const { knownTags } = state;
const { name } = action.data; const { name } = action.data;
let newKnownTags = _extends$g({}, knownTags); let newKnownTags = _extends$f({}, knownTags);
newKnownTags[name] = { name }; newKnownTags[name] = { name };
return _extends$g({}, state, { return _extends$f({}, state, {
knownTags: newKnownTags knownTags: newKnownTags
}); });
}, },
@ -6425,11 +6371,11 @@ const tagsReducer = handleActions({
const { knownTags, followedTags } = state; const { knownTags, followedTags } = state;
const { name } = action.data; const { name } = action.data;
let newKnownTags = _extends$g({}, knownTags); let newKnownTags = _extends$f({}, knownTags);
delete newKnownTags[name]; delete newKnownTags[name];
const newFollowedTags = followedTags.filter(tag => tag !== name); const newFollowedTags = followedTags.filter(tag => tag !== name);
return _extends$g({}, state, { return _extends$f({}, state, {
knownTags: newKnownTags, knownTags: newKnownTags,
followedTags: newFollowedTags followedTags: newFollowedTags
}); });
@ -6437,17 +6383,17 @@ const tagsReducer = handleActions({
[USER_STATE_POPULATE]: (state, action) => { [USER_STATE_POPULATE]: (state, action) => {
const { tags } = action.data; const { tags } = action.data;
if (Array.isArray(tags)) { if (Array.isArray(tags)) {
return _extends$g({}, state, { return _extends$f({}, state, {
followedTags: tags followedTags: tags
}); });
} }
return _extends$g({}, state); return _extends$f({}, state);
} }
}, defaultState$8); }, defaultState$7);
var _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const defaultState$9 = { const defaultState$8 = {
blockedChannels: [] blockedChannels: []
}; };
@ -6469,13 +6415,13 @@ const blockedReducer = handleActions({
}, },
[USER_STATE_POPULATE]: (state, action) => { [USER_STATE_POPULATE]: (state, action) => {
const { blocked } = action.data; const { blocked } = action.data;
return _extends$h({}, state, { return _extends$g({}, state, {
blockedChannels: blocked && blocked.length ? blocked : state.blockedChannels blockedChannels: blocked && blocked.length ? blocked : state.blockedChannels
}); });
} }
}, defaultState$9); }, defaultState$8);
var _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const buildDraftTransaction = () => ({ const buildDraftTransaction = () => ({
amount: undefined, amount: undefined,
@ -6486,7 +6432,7 @@ const buildDraftTransaction = () => ({
// See details in https://github.com/lbryio/lbry/issues/1307 // See details in https://github.com/lbryio/lbry/issues/1307
const defaultState$a = { const defaultState$9 = {
balance: undefined, balance: undefined,
totalBalance: undefined, totalBalance: undefined,
reservedBalance: undefined, reservedBalance: undefined,
@ -6527,40 +6473,40 @@ const defaultState$a = {
}; };
const walletReducer = handleActions({ const walletReducer = handleActions({
[FETCH_TRANSACTIONS_STARTED]: state => _extends$i({}, state, { [FETCH_TRANSACTIONS_STARTED]: state => _extends$h({}, state, {
fetchingTransactions: true fetchingTransactions: true
}), }),
[FETCH_TRANSACTIONS_COMPLETED]: (state, action) => { [FETCH_TRANSACTIONS_COMPLETED]: (state, action) => {
const byId = _extends$i({}, state.transactions); const byId = _extends$h({}, state.transactions);
const { transactions } = action.data; const { transactions } = action.data;
transactions.forEach(transaction => { transactions.forEach(transaction => {
byId[transaction.txid] = transaction; byId[transaction.txid] = transaction;
}); });
return _extends$i({}, state, { return _extends$h({}, state, {
transactions: byId, transactions: byId,
fetchingTransactions: false fetchingTransactions: false
}); });
}, },
[FETCH_TXO_PAGE_STARTED]: state => { [FETCH_TXO_PAGE_STARTED]: state => {
return _extends$i({}, state, { return _extends$h({}, state, {
fetchingTxos: true, fetchingTxos: true,
fetchingTxosError: undefined fetchingTxosError: undefined
}); });
}, },
[FETCH_TXO_PAGE_COMPLETED]: (state, action) => { [FETCH_TXO_PAGE_COMPLETED]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
txoPage: action.data, txoPage: action.data,
fetchingTxos: false fetchingTxos: false
}); });
}, },
[FETCH_TXO_PAGE_FAILED]: (state, action) => { [FETCH_TXO_PAGE_FAILED]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
txoPage: {}, txoPage: {},
fetchingTxos: false, fetchingTxos: false,
fetchingTxosError: action.data fetchingTxosError: action.data
@ -6568,12 +6514,12 @@ const walletReducer = handleActions({
}, },
[UPDATE_TXO_FETCH_PARAMS]: (state, action) => { [UPDATE_TXO_FETCH_PARAMS]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
txoFetchParams: action.data txoFetchParams: action.data
}); });
}, },
[FETCH_SUPPORTS_STARTED]: state => _extends$i({}, state, { [FETCH_SUPPORTS_STARTED]: state => _extends$h({}, state, {
fetchingSupports: true fetchingSupports: true
}), }),
@ -6586,7 +6532,7 @@ const walletReducer = handleActions({
byOutpoint[`${txid}:${nout}`] = transaction; byOutpoint[`${txid}:${nout}`] = transaction;
}); });
return _extends$i({}, state, { supports: byOutpoint, fetchingSupports: false }); return _extends$h({}, state, { supports: byOutpoint, fetchingSupports: false });
}, },
[ABANDON_SUPPORT_STARTED]: (state, action) => { [ABANDON_SUPPORT_STARTED]: (state, action) => {
@ -6595,7 +6541,7 @@ const walletReducer = handleActions({
currentlyAbandoning[outpoint] = true; currentlyAbandoning[outpoint] = true;
return _extends$i({}, state, { return _extends$h({}, state, {
abandoningSupportsByOutpoint: currentlyAbandoning abandoningSupportsByOutpoint: currentlyAbandoning
}); });
}, },
@ -6608,20 +6554,20 @@ const walletReducer = handleActions({
delete currentlyAbandoning[outpoint]; delete currentlyAbandoning[outpoint];
delete byOutpoint[outpoint]; delete byOutpoint[outpoint];
return _extends$i({}, state, { return _extends$h({}, state, {
supports: byOutpoint, supports: byOutpoint,
abandoningSupportsById: currentlyAbandoning abandoningSupportsById: currentlyAbandoning
}); });
}, },
[ABANDON_CLAIM_SUPPORT_STARTED]: (state, action) => { [ABANDON_CLAIM_SUPPORT_STARTED]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
abandonClaimSupportError: undefined abandonClaimSupportError: undefined
}); });
}, },
[ABANDON_CLAIM_SUPPORT_PREVIEW]: (state, action) => { [ABANDON_CLAIM_SUPPORT_PREVIEW]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
abandonClaimSupportError: undefined abandonClaimSupportError: undefined
}); });
}, },
@ -6632,36 +6578,36 @@ const walletReducer = handleActions({
pendingtxs[claimId] = { txid, type, effective }; pendingtxs[claimId] = { txid, type, effective };
return _extends$i({}, state, { return _extends$h({}, state, {
pendingSupportTransactions: pendingtxs, pendingSupportTransactions: pendingtxs,
abandonClaimSupportError: undefined abandonClaimSupportError: undefined
}); });
}, },
[ABANDON_CLAIM_SUPPORT_FAILED]: (state, action) => { [ABANDON_CLAIM_SUPPORT_FAILED]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
abandonClaimSupportError: action.data abandonClaimSupportError: action.data
}); });
}, },
[PENDING_SUPPORTS_UPDATED]: (state, action) => { [PENDING_SUPPORTS_UPDATED]: (state, action) => {
return _extends$i({}, state, { return _extends$h({}, state, {
pendingSupportTransactions: action.data pendingSupportTransactions: action.data
}); });
}, },
[GET_NEW_ADDRESS_STARTED]: state => _extends$i({}, state, { [GET_NEW_ADDRESS_STARTED]: state => _extends$h({}, state, {
gettingNewAddress: true gettingNewAddress: true
}), }),
[GET_NEW_ADDRESS_COMPLETED]: (state, action) => { [GET_NEW_ADDRESS_COMPLETED]: (state, action) => {
const { address } = action.data; const { address } = action.data;
return _extends$i({}, state, { gettingNewAddress: false, receiveAddress: address }); return _extends$h({}, state, { gettingNewAddress: false, receiveAddress: address });
}, },
[UPDATE_BALANCE]: (state, action) => _extends$i({}, state, { [UPDATE_BALANCE]: (state, action) => _extends$h({}, state, {
totalBalance: action.data.totalBalance, totalBalance: action.data.totalBalance,
balance: action.data.balance, balance: action.data.balance,
reservedBalance: action.data.reservedBalance, reservedBalance: action.data.reservedBalance,
@ -6670,32 +6616,32 @@ const walletReducer = handleActions({
tipsBalance: action.data.tipsBalance tipsBalance: action.data.tipsBalance
}), }),
[CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$i({}, state, { [CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$h({}, state, {
checkingAddressOwnership: true checkingAddressOwnership: true
}), }),
[CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$i({}, state, { [CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$h({}, state, {
checkingAddressOwnership: false checkingAddressOwnership: false
}), }),
[SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => { [SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => {
const oldDraft = state.draftTransaction; const oldDraft = state.draftTransaction;
const newDraft = _extends$i({}, oldDraft, { amount: parseFloat(action.data.amount) }); const newDraft = _extends$h({}, oldDraft, { amount: parseFloat(action.data.amount) });
return _extends$i({}, state, { draftTransaction: newDraft }); return _extends$h({}, state, { draftTransaction: newDraft });
}, },
[SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => { [SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => {
const oldDraft = state.draftTransaction; const oldDraft = state.draftTransaction;
const newDraft = _extends$i({}, oldDraft, { address: action.data.address }); const newDraft = _extends$h({}, oldDraft, { address: action.data.address });
return _extends$i({}, state, { draftTransaction: newDraft }); return _extends$h({}, state, { draftTransaction: newDraft });
}, },
[SEND_TRANSACTION_STARTED]: state => { [SEND_TRANSACTION_STARTED]: state => {
const newDraftTransaction = _extends$i({}, state.draftTransaction, { sending: true }); const newDraftTransaction = _extends$h({}, state.draftTransaction, { sending: true });
return _extends$i({}, state, { draftTransaction: newDraftTransaction }); return _extends$h({}, state, { draftTransaction: newDraftTransaction });
}, },
[SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, { [SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, {
@ -6708,123 +6654,123 @@ const walletReducer = handleActions({
error: action.data.error error: action.data.error
}); });
return _extends$i({}, state, { draftTransaction: newDraftTransaction }); return _extends$h({}, state, { draftTransaction: newDraftTransaction });
}, },
[SUPPORT_TRANSACTION_STARTED]: state => _extends$i({}, state, { [SUPPORT_TRANSACTION_STARTED]: state => _extends$h({}, state, {
sendingSupport: true sendingSupport: true
}), }),
[SUPPORT_TRANSACTION_COMPLETED]: state => _extends$i({}, state, { [SUPPORT_TRANSACTION_COMPLETED]: state => _extends$h({}, state, {
sendingSupport: false sendingSupport: false
}), }),
[SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$i({}, state, { [SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$h({}, state, {
error: action.data.error, error: action.data.error,
sendingSupport: false sendingSupport: false
}), }),
[CLEAR_SUPPORT_TRANSACTION]: state => _extends$i({}, state, { [CLEAR_SUPPORT_TRANSACTION]: state => _extends$h({}, state, {
sendingSupport: false sendingSupport: false
}), }),
[WALLET_STATUS_COMPLETED]: (state, action) => _extends$i({}, state, { [WALLET_STATUS_COMPLETED]: (state, action) => _extends$h({}, state, {
walletIsEncrypted: action.result walletIsEncrypted: action.result
}), }),
[WALLET_ENCRYPT_START]: state => _extends$i({}, state, { [WALLET_ENCRYPT_START]: state => _extends$h({}, state, {
walletEncryptPending: true, walletEncryptPending: true,
walletEncryptSucceded: null, walletEncryptSucceded: null,
walletEncryptResult: null walletEncryptResult: null
}), }),
[WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$i({}, state, { [WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$h({}, state, {
walletEncryptPending: false, walletEncryptPending: false,
walletEncryptSucceded: true, walletEncryptSucceded: true,
walletEncryptResult: action.result walletEncryptResult: action.result
}), }),
[WALLET_ENCRYPT_FAILED]: (state, action) => _extends$i({}, state, { [WALLET_ENCRYPT_FAILED]: (state, action) => _extends$h({}, state, {
walletEncryptPending: false, walletEncryptPending: false,
walletEncryptSucceded: false, walletEncryptSucceded: false,
walletEncryptResult: action.result walletEncryptResult: action.result
}), }),
[WALLET_DECRYPT_START]: state => _extends$i({}, state, { [WALLET_DECRYPT_START]: state => _extends$h({}, state, {
walletDecryptPending: true, walletDecryptPending: true,
walletDecryptSucceded: null, walletDecryptSucceded: null,
walletDecryptResult: null walletDecryptResult: null
}), }),
[WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$i({}, state, { [WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$h({}, state, {
walletDecryptPending: false, walletDecryptPending: false,
walletDecryptSucceded: true, walletDecryptSucceded: true,
walletDecryptResult: action.result walletDecryptResult: action.result
}), }),
[WALLET_DECRYPT_FAILED]: (state, action) => _extends$i({}, state, { [WALLET_DECRYPT_FAILED]: (state, action) => _extends$h({}, state, {
walletDecryptPending: false, walletDecryptPending: false,
walletDecryptSucceded: false, walletDecryptSucceded: false,
walletDecryptResult: action.result walletDecryptResult: action.result
}), }),
[WALLET_UNLOCK_START]: state => _extends$i({}, state, { [WALLET_UNLOCK_START]: state => _extends$h({}, state, {
walletUnlockPending: true, walletUnlockPending: true,
walletUnlockSucceded: null, walletUnlockSucceded: null,
walletUnlockResult: null walletUnlockResult: null
}), }),
[WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$i({}, state, { [WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$h({}, state, {
walletUnlockPending: false, walletUnlockPending: false,
walletUnlockSucceded: true, walletUnlockSucceded: true,
walletUnlockResult: action.result walletUnlockResult: action.result
}), }),
[WALLET_UNLOCK_FAILED]: (state, action) => _extends$i({}, state, { [WALLET_UNLOCK_FAILED]: (state, action) => _extends$h({}, state, {
walletUnlockPending: false, walletUnlockPending: false,
walletUnlockSucceded: false, walletUnlockSucceded: false,
walletUnlockResult: action.result walletUnlockResult: action.result
}), }),
[WALLET_LOCK_START]: state => _extends$i({}, state, { [WALLET_LOCK_START]: state => _extends$h({}, state, {
walletLockPending: false, walletLockPending: false,
walletLockSucceded: null, walletLockSucceded: null,
walletLockResult: null walletLockResult: null
}), }),
[WALLET_LOCK_COMPLETED]: (state, action) => _extends$i({}, state, { [WALLET_LOCK_COMPLETED]: (state, action) => _extends$h({}, state, {
walletLockPending: false, walletLockPending: false,
walletLockSucceded: true, walletLockSucceded: true,
walletLockResult: action.result walletLockResult: action.result
}), }),
[WALLET_LOCK_FAILED]: (state, action) => _extends$i({}, state, { [WALLET_LOCK_FAILED]: (state, action) => _extends$h({}, state, {
walletLockPending: false, walletLockPending: false,
walletLockSucceded: false, walletLockSucceded: false,
walletLockResult: action.result walletLockResult: action.result
}), }),
[SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$i({}, state, { [SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$h({}, state, {
transactionListFilter: action.data transactionListFilter: action.data
}), }),
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$i({}, state, { [UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$h({}, state, {
latestBlock: action.data latestBlock: action.data
}), }),
[WALLET_RESTART]: state => _extends$i({}, state, { [WALLET_RESTART]: state => _extends$h({}, state, {
walletReconnecting: true walletReconnecting: true
}), }),
[WALLET_RESTART_COMPLETED]: state => _extends$i({}, state, { [WALLET_RESTART_COMPLETED]: state => _extends$h({}, state, {
walletReconnecting: false walletReconnecting: false
}) })
}, defaultState$a); }, defaultState$9);
// //
const selectState$6 = state => state.content || {}; const selectState$5 = state => state.content || {};
const makeSelectContentPositionForUri = uri => reselect.createSelector(selectState$6, makeSelectClaimForUri(uri), (state, claim) => { const makeSelectContentPositionForUri = uri => reselect.createSelector(selectState$5, makeSelectClaimForUri(uri), (state, claim) => {
if (!claim) { if (!claim) {
return null; return null;
} }
@ -6833,14 +6779,14 @@ const makeSelectContentPositionForUri = uri => reselect.createSelector(selectSta
return state.positions[id] ? state.positions[id][outpoint] : null; return state.positions[id] ? state.positions[id][outpoint] : null;
}); });
var _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const selectState$7 = state => state.notifications || {}; const selectState$6 = state => state.notifications || {};
const selectToast = reselect.createSelector(selectState$7, state => { const selectToast = reselect.createSelector(selectState$6, state => {
if (state.toasts.length) { if (state.toasts.length) {
const { id, params } = state.toasts[0]; const { id, params } = state.toasts[0];
return _extends$j({ return _extends$i({
id id
}, params); }, params);
} }
@ -6848,7 +6794,7 @@ const selectToast = reselect.createSelector(selectState$7, state => {
return null; return null;
}); });
const selectError = reselect.createSelector(selectState$7, state => { const selectError = reselect.createSelector(selectState$6, state => {
if (state.errors.length) { if (state.errors.length) {
const { error } = state.errors[0]; const { error } = state.errors[0];
return { return {
@ -6861,11 +6807,11 @@ const selectError = reselect.createSelector(selectState$7, state => {
// //
const selectState$8 = state => state.comments || {}; const selectState$7 = state => state.comments || {};
const selectCommentsById = reselect.createSelector(selectState$8, state => state.commentById || {}); const selectCommentsById = reselect.createSelector(selectState$7, state => state.commentById || {});
const selectCommentsByClaimId = reselect.createSelector(selectState$8, selectCommentsById, (state, byId) => { const selectCommentsByClaimId = reselect.createSelector(selectState$7, selectCommentsById, (state, byId) => {
const byClaimId = state.byId || {}; const byClaimId = state.byId || {};
const comments = {}; const comments = {};
@ -6887,7 +6833,7 @@ const selectCommentsByClaimId = reselect.createSelector(selectState$8, selectCom
selectState, selectState,
state => state.byId || {} state => state.byId || {}
); */ ); */
const selectCommentsByUri = reselect.createSelector(selectState$8, state => { const selectCommentsByUri = reselect.createSelector(selectState$7, state => {
const byUri = state.commentsByUri || {}; const byUri = state.commentsByUri || {};
const comments = {}; const comments = {};
Object.keys(byUri).forEach(uri => { Object.keys(byUri).forEach(uri => {
@ -6912,11 +6858,11 @@ const makeSelectCommentsForUri = uri => reselect.createSelector(selectCommentsBy
// //
const selectState$9 = state => state.tags || {}; const selectState$8 = state => state.tags || {};
const selectKnownTagsByName = reselect.createSelector(selectState$9, state => state.knownTags); const selectKnownTagsByName = reselect.createSelector(selectState$8, state => state.knownTags);
const selectFollowedTagsList = reselect.createSelector(selectState$9, state => state.followedTags.filter(tag => typeof tag === 'string')); const selectFollowedTagsList = reselect.createSelector(selectState$8, state => state.followedTags.filter(tag => typeof tag === 'string'));
const selectFollowedTags = reselect.createSelector(selectFollowedTagsList, followedTags => followedTags.map(tag => ({ name: tag.toLowerCase() })).sort((a, b) => a.name.localeCompare(b.name))); const selectFollowedTags = reselect.createSelector(selectFollowedTagsList, followedTags => followedTags.map(tag => ({ name: tag.toLowerCase() })).sort((a, b) => a.name.localeCompare(b.name)));
@ -6939,9 +6885,9 @@ const makeSelectIsFollowingTag = tag => reselect.createSelector(selectFollowedTa
// //
const selectState$a = state => state.blocked || {}; const selectState$9 = state => state.blocked || {};
const selectBlockedChannels = reselect.createSelector(selectState$a, state => state.blockedChannels); const selectBlockedChannels = reselect.createSelector(selectState$9, state => state.blockedChannels);
const selectBlockedChannelsCount = reselect.createSelector(selectBlockedChannels, state => state.length); const selectBlockedChannelsCount = reselect.createSelector(selectBlockedChannels, state => state.length);
@ -7053,7 +6999,6 @@ exports.doWalletReconnect = doWalletReconnect;
exports.doWalletStatus = doWalletStatus; exports.doWalletStatus = doWalletStatus;
exports.doWalletUnlock = doWalletUnlock; exports.doWalletUnlock = doWalletUnlock;
exports.fileInfoReducer = fileInfoReducer; exports.fileInfoReducer = fileInfoReducer;
exports.fileReducer = fileReducer;
exports.formatCredits = formatCredits; exports.formatCredits = formatCredits;
exports.formatFullPrice = formatFullPrice; exports.formatFullPrice = formatFullPrice;
exports.isClaimNsfw = isClaimNsfw; exports.isClaimNsfw = isClaimNsfw;
@ -7158,7 +7103,6 @@ exports.selectDraftTransactionAddress = selectDraftTransactionAddress;
exports.selectDraftTransactionAmount = selectDraftTransactionAmount; exports.selectDraftTransactionAmount = selectDraftTransactionAmount;
exports.selectDraftTransactionError = selectDraftTransactionError; exports.selectDraftTransactionError = selectDraftTransactionError;
exports.selectError = selectError; exports.selectError = selectError;
exports.selectFailedPurchaseUris = selectFailedPurchaseUris;
exports.selectFetchingClaimSearch = selectFetchingClaimSearch; exports.selectFetchingClaimSearch = selectFetchingClaimSearch;
exports.selectFetchingClaimSearchByQuery = selectFetchingClaimSearchByQuery; exports.selectFetchingClaimSearchByQuery = selectFetchingClaimSearchByQuery;
exports.selectFetchingMyChannels = selectFetchingMyChannels; exports.selectFetchingMyChannels = selectFetchingMyChannels;
@ -7186,7 +7130,6 @@ exports.selectIsSearching = selectIsSearching;
exports.selectIsSendingSupport = selectIsSendingSupport; exports.selectIsSendingSupport = selectIsSendingSupport;
exports.selectIsStillEditing = selectIsStillEditing; exports.selectIsStillEditing = selectIsStillEditing;
exports.selectIsWalletReconnecting = selectIsWalletReconnecting; exports.selectIsWalletReconnecting = selectIsWalletReconnecting;
exports.selectLastPurchasedUri = selectLastPurchasedUri;
exports.selectMyActiveClaims = selectMyActiveClaims; exports.selectMyActiveClaims = selectMyActiveClaims;
exports.selectMyChannelClaims = selectMyChannelClaims; exports.selectMyChannelClaims = selectMyChannelClaims;
exports.selectMyClaimForUri = selectMyClaimForUri; exports.selectMyClaimForUri = selectMyClaimForUri;
@ -7206,8 +7149,7 @@ exports.selectPendingClaims = selectPendingClaims;
exports.selectPendingSupportTransactions = selectPendingSupportTransactions; exports.selectPendingSupportTransactions = selectPendingSupportTransactions;
exports.selectPlayingUri = selectPlayingUri; exports.selectPlayingUri = selectPlayingUri;
exports.selectPublishFormValues = selectPublishFormValues; exports.selectPublishFormValues = selectPublishFormValues;
exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage; exports.selectPurchaseUriSuccess = selectPurchaseUriSuccess;
exports.selectPurchasedUris = selectPurchasedUris;
exports.selectReceiveAddress = selectReceiveAddress; exports.selectReceiveAddress = selectReceiveAddress;
exports.selectRecentTransactions = selectRecentTransactions; exports.selectRecentTransactions = selectRecentTransactions;
exports.selectReflectingById = selectReflectingById; exports.selectReflectingById = selectReflectingById;

View file

@ -11,6 +11,7 @@ declare type FileListItem = {
claim_id: string, claim_id: string,
claim_name: string, claim_name: string,
completed: false, completed: false,
content_fee?: {},
download_directory: string, download_directory: string,
download_path: string, download_path: string,
file_name: string, file_name: string,

1
flow-typed/File.js vendored
View file

@ -11,6 +11,7 @@ declare type FileListItem = {
claim_id: string, claim_id: string,
claim_name: string, claim_name: string,
completed: false, completed: false,
content_fee?: {},
download_directory: string, download_directory: string,
download_path: string, download_path: string,
file_name: string, file_name: string,

View file

@ -158,7 +158,6 @@ export { claimsReducer } from 'redux/reducers/claims';
export { commentReducer } from 'redux/reducers/comments'; export { commentReducer } from 'redux/reducers/comments';
export { contentReducer } from 'redux/reducers/content'; export { contentReducer } from 'redux/reducers/content';
export { fileInfoReducer } from 'redux/reducers/file_info'; export { fileInfoReducer } from 'redux/reducers/file_info';
export { fileReducer } from 'redux/reducers/file';
export { notificationsReducer } from 'redux/reducers/notifications'; export { notificationsReducer } from 'redux/reducers/notifications';
export { publishReducer } from 'redux/reducers/publish'; export { publishReducer } from 'redux/reducers/publish';
export { searchReducer } from 'redux/reducers/search'; export { searchReducer } from 'redux/reducers/search';
@ -171,14 +170,6 @@ export { makeSelectContentPositionForUri } from 'redux/selectors/content';
export { selectToast, selectError } from 'redux/selectors/notifications'; export { selectToast, selectError } from 'redux/selectors/notifications';
export {
selectFailedPurchaseUris,
selectPurchasedUris,
selectPurchaseUriErrorMessage,
selectLastPurchasedUri,
makeSelectStreamingUrlForUri,
} from 'redux/selectors/file';
export { export {
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectClaimIsMine, makeSelectClaimIsMine,
@ -260,6 +251,7 @@ export {
selectIsFetchingMyPurchases, selectIsFetchingMyPurchases,
selectFetchingMyPurchasesError, selectFetchingMyPurchasesError,
selectMyPurchasesCount, selectMyPurchasesCount,
selectPurchaseUriSuccess,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
export { makeSelectCommentsForUri } from 'redux/selectors/comments'; export { makeSelectCommentsForUri } from 'redux/selectors/comments';
@ -287,6 +279,7 @@ export {
makeSelectSearchDownloadUrlsForPage, makeSelectSearchDownloadUrlsForPage,
makeSelectSearchDownloadUrlsCount, makeSelectSearchDownloadUrlsCount,
selectDownloadUrlsCount, selectDownloadUrlsCount,
makeSelectStreamingUrlForUri,
} from 'redux/selectors/file_info'; } from 'redux/selectors/file_info';
export { export {

View file

@ -3,8 +3,11 @@ import * as ACTIONS from 'constants/action_types';
import Lbry from 'lbry'; import Lbry from 'lbry';
import { doToast } from 'redux/actions/notifications'; import { doToast } from 'redux/actions/notifications';
import { selectBalance } from 'redux/selectors/wallet'; import { selectBalance } from 'redux/selectors/wallet';
import { makeSelectFileInfoForUri, selectDownloadingByOutpoint } from 'redux/selectors/file_info'; import {
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file'; makeSelectFileInfoForUri,
selectDownloadingByOutpoint,
makeSelectStreamingUrlForUri,
} from 'redux/selectors/file_info';
import { makeSelectClaimForUri } from 'redux/selectors/claims'; import { makeSelectClaimForUri } from 'redux/selectors/claims';
type Dispatch = (action: any) => any; type Dispatch = (action: any) => any;
@ -28,7 +31,6 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
.then((streamInfo: GetResponse) => { .then((streamInfo: GetResponse) => {
const timeout = const timeout =
streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout'; streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout';
if (timeout) { if (timeout) {
dispatch({ dispatch({
type: ACTIONS.FETCH_FILE_INFO_FAILED, type: ACTIONS.FETCH_FILE_INFO_FAILED,
@ -37,11 +39,12 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true })); dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
} else { } else {
// purchase was completed successfully if (streamInfo.content_fee) {
dispatch({ dispatch({
type: ACTIONS.PURCHASE_URI_COMPLETED, type: ACTIONS.PURCHASE_URI_COMPLETED,
data: { uri }, data: { uri, purchaseReceipt: streamInfo.content_fee },
}); });
}
dispatch({ dispatch({
type: ACTIONS.FETCH_FILE_INFO_COMPLETED, type: ACTIONS.FETCH_FILE_INFO_COMPLETED,
data: { data: {
@ -55,10 +58,10 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
} }
} }
}) })
.catch(() => { .catch(error => {
dispatch({ dispatch({
type: ACTIONS.PURCHASE_URI_FAILED, type: ACTIONS.PURCHASE_URI_FAILED,
data: { uri }, data: { uri, error },
}); });
dispatch({ dispatch({

View file

@ -25,6 +25,7 @@ type State = {
fetchingChannelClaims: { [string]: number }, fetchingChannelClaims: { [string]: number },
fetchingMyChannels: boolean, fetchingMyChannels: boolean,
fetchingClaimSearchByQuery: { [string]: boolean }, fetchingClaimSearchByQuery: { [string]: boolean },
purchaseUriSuccess: boolean,
myPurchases: ?Array<string>, myPurchases: ?Array<string>,
myPurchasesPageNumber: ?number, myPurchasesPageNumber: ?number,
myPurchasesPageTotalResults: ?number, myPurchasesPageTotalResults: ?number,
@ -69,6 +70,7 @@ const defaultState = {
myPurchases: undefined, myPurchases: undefined,
myPurchasesPageNumber: undefined, myPurchasesPageNumber: undefined,
myPurchasesPageTotalResults: undefined, myPurchasesPageTotalResults: undefined,
purchaseUriSuccess: false,
fetchingMyPurchases: false, fetchingMyPurchases: false,
fetchingMyPurchasesError: undefined, fetchingMyPurchasesError: undefined,
fetchingMyChannels: false, fetchingMyChannels: false,
@ -700,6 +702,37 @@ reducers[ACTIONS.PURCHASE_LIST_FAILED] = (state: State, action: any): State => {
}; };
}; };
reducers[ACTIONS.PURCHASE_URI_COMPLETED] = (state: State, action: any): State => {
const { uri, purchaseReceipt } = action.data;
let byId = Object.assign({}, state.byId);
let byUri = Object.assign({}, state.claimsByUri);
let myPurchases = state.myPurchases ? state.myPurchases.slice() : [];
let urlsForCurrentPage = [];
const claimId = byUri[uri];
if (claimId) {
let claim = byId[claimId];
claim.purchase_receipt = purchaseReceipt;
}
myPurchases.push(uri);
return {
...state,
byId,
myPurchases,
purchaseUriSuccess: true,
};
};
reducers[ACTIONS.PURCHASE_URI_FAILED] = (state: State): State => {
return {
...state,
purchaseUriSuccess: false,
};
};
export function claimsReducer(state: State = defaultState, action: any) { export function claimsReducer(state: State = 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);

View file

@ -1,89 +0,0 @@
// @flow
import * as ACTIONS from 'constants/action_types';
const reducers = {};
const defaultState = {
failedPurchaseUris: [],
purchasedUris: [],
purchaseUriErrorMessage: '',
};
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,
purchaseUriErrorMessage: '',
};
};
reducers[ACTIONS.PURCHASE_URI_COMPLETED] = (
state: FileState,
action: PurchaseUriCompleted
): FileState => {
const { uri } = action.data;
const newPurchasedUris = state.purchasedUris.slice();
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
if (!newPurchasedUris.includes(uri)) {
newPurchasedUris.push(uri);
}
if (newFailedPurchaseUris.includes(uri)) {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
}
return {
...state,
failedPurchaseUris: newFailedPurchaseUris,
purchasedUris: newPurchasedUris,
purchaseUriErrorMessage: '',
};
};
reducers[ACTIONS.PURCHASE_URI_FAILED] = (
state: FileState,
action: PurchaseUriFailed
): FileState => {
const { uri, error } = action.data;
const newFailedPurchaseUris = state.failedPurchaseUris.slice();
if (!newFailedPurchaseUris.includes(uri)) {
newFailedPurchaseUris.push(uri);
}
return {
...state,
failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: error,
};
};
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) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
return state;
}

View file

@ -231,6 +231,11 @@ export const selectMyPurchases = createSelector(
state => state.myPurchases state => state.myPurchases
); );
export const selectPurchaseUriSuccess = createSelector(
selectState,
state => state.purchaseUriSuccess
);
export const selectMyPurchasesCount = createSelector( export const selectMyPurchasesCount = createSelector(
selectState, selectState,
state => state.myPurchasesPageTotalResults state => state.myPurchasesPageTotalResults
@ -400,7 +405,9 @@ export const makeSelectThumbnailForUri = (uri: string) =>
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),
claim => { claim => {
const thumbnail = claim && claim.value && claim.value.thumbnail; const thumbnail = claim && claim.value && claim.value.thumbnail;
return thumbnail && thumbnail.url ? thumbnail.url.trim().replace(/^http:\/\//i, 'https://') : undefined; return thumbnail && thumbnail.url
? thumbnail.url.trim().replace(/^http:\/\//i, 'https://')
: undefined;
} }
); );

View file

@ -1,36 +0,0 @@
// @flow
import { createSelector } from 'reselect';
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
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
);
export const selectPurchasedUris: (state: State) => Array<string> = createSelector(
selectState,
state => state.purchasedUris
);
export const selectLastPurchasedUri: (state: State) => string = createSelector(
selectState,
state =>
state.purchasedUris.length > 0 ? state.purchasedUris[state.purchasedUris.length - 1] : null
);
export const makeSelectStreamingUrlForUri = (uri: string) =>
createSelector(
makeSelectFileInfoForUri(uri),
fileInfo => {
return fileInfo && fileInfo.streaming_url;
}
);

View file

@ -234,12 +234,12 @@ export const makeSelectSearchDownloadUrlsForPage = (query, page = 1) =>
return matchingFileInfos && matchingFileInfos.length return matchingFileInfos && matchingFileInfos.length
? matchingFileInfos.slice(start, end).map(fileInfo => ? matchingFileInfos.slice(start, end).map(fileInfo =>
buildURI({ buildURI({
streamName: fileInfo.claim_name, streamName: fileInfo.claim_name,
channelName: fileInfo.channel_name, channelName: fileInfo.channel_name,
channelClaimId: fileInfo.channel_claim_id, channelClaimId: fileInfo.channel_claim_id,
}) })
) )
: []; : [];
} }
); );
@ -251,3 +251,11 @@ export const makeSelectSearchDownloadUrlsCount = query =>
return fileInfos && fileInfos.length ? filterFileInfos(fileInfos, query).length : 0; return fileInfos && fileInfos.length ? filterFileInfos(fileInfos, query).length : 0;
} }
); );
export const makeSelectStreamingUrlForUri = uri =>
createSelector(
makeSelectFileInfoForUri(uri),
fileInfo => {
return fileInfo && fileInfo.streaming_url;
}
);