use FETCH_FILE_INFO_XXX in favor of LOADING_URI_XXX

This commit is contained in:
Sean Yesmunt 2019-08-13 13:33:32 -04:00
parent fe66fae040
commit 291b068642
4 changed files with 133 additions and 163 deletions

230
dist/bundle.es.js vendored
View file

@ -137,6 +137,7 @@ const FILE_LIST_STARTED = 'FILE_LIST_STARTED';
const FILE_LIST_SUCCEEDED = 'FILE_LIST_SUCCEEDED';
const FETCH_FILE_INFO_STARTED = 'FETCH_FILE_INFO_STARTED';
const FETCH_FILE_INFO_COMPLETED = 'FETCH_FILE_INFO_COMPLETED';
const FETCH_FILE_INFO_FAILED = 'FETCH_FILE_INFO_FAILED';
const LOADING_VIDEO_STARTED = 'LOADING_VIDEO_STARTED';
const LOADING_VIDEO_COMPLETED = 'LOADING_VIDEO_COMPLETED';
const LOADING_VIDEO_FAILED = 'LOADING_VIDEO_FAILED';
@ -363,6 +364,7 @@ var action_types = /*#__PURE__*/Object.freeze({
FILE_LIST_SUCCEEDED: FILE_LIST_SUCCEEDED,
FETCH_FILE_INFO_STARTED: FETCH_FILE_INFO_STARTED,
FETCH_FILE_INFO_COMPLETED: FETCH_FILE_INFO_COMPLETED,
FETCH_FILE_INFO_FAILED: FETCH_FILE_INFO_FAILED,
LOADING_VIDEO_STARTED: LOADING_VIDEO_STARTED,
LOADING_VIDEO_COMPLETED: LOADING_VIDEO_COMPLETED,
LOADING_VIDEO_FAILED: LOADING_VIDEO_FAILED,
@ -2630,11 +2632,15 @@ const makeSelectStreamingUrlForUri = uri => reselect.createSelector(makeSelectFi
//
function doFileGet(uri, saveFile = true, onSuccess) {
return dispatch => {
return (dispatch, getState) => {
const state = getState();
const { nout, txid } = makeSelectClaimForUri(uri)(state);
const outpoint = `${txid}:${nout}`;
dispatch({
type: PURCHASE_URI_STARTED,
type: FETCH_FILE_INFO_STARTED,
data: {
uri
outpoint
}
});
@ -2644,8 +2650,8 @@ function doFileGet(uri, saveFile = true, onSuccess) {
if (timeout) {
dispatch({
type: PURCHASE_URI_FAILED,
data: { uri }
type: FETCH_FILE_INFO_FAILED,
data: { outpoint }
});
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
@ -2673,6 +2679,11 @@ function doFileGet(uri, saveFile = true, onSuccess) {
data: { uri }
});
dispatch({
type: FETCH_FILE_INFO_FAILED,
data: { outpoint }
});
dispatch(doToast({
message: `Failed to view ${uri}, please try again. If this problem persists, visit https://lbry.com/faq/support for support.`,
isError: true
@ -3858,8 +3869,6 @@ function contentReducer(state = defaultState$2, action) {
return state;
}
var _extends$8 = 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$2 = {};
const defaultState$3 = {
fileListPublishedSort: DATE_NEW,
@ -3914,20 +3923,27 @@ reducers$2[FETCH_FILE_INFO_COMPLETED] = (state, action) => {
});
};
reducers$2[FETCH_FILE_INFO_FAILED] = (state, action) => {
const { outpoint } = action.data;
const newFetching = Object.assign({}, state.fetching);
delete newFetching[outpoint];
return Object.assign({}, state, {
fetching: newFetching
});
};
reducers$2[DOWNLOADING_STARTED] = (state, action) => {
const { uri, outpoint, fileInfo } = action.data;
const newByOutpoint = Object.assign({}, state.byOutpoint);
const newDownloading = Object.assign({}, state.downloadingByOutpoint);
const newLoading = Object.assign({}, state.urisLoading);
newDownloading[outpoint] = true;
newByOutpoint[outpoint] = fileInfo;
delete newLoading[uri];
return Object.assign({}, state, {
downloadingByOutpoint: newDownloading,
urisLoading: newLoading,
byOutpoint: newByOutpoint
});
};
@ -3952,11 +3968,9 @@ reducers$2[DOWNLOADING_CANCELED] = (state, action) => {
const newDownloading = Object.assign({}, state.downloadingByOutpoint);
delete newDownloading[outpoint];
delete newLoading[uri];
return Object.assign({}, state, {
downloadingByOutpoint: newDownloading,
urisLoading: newLoading
downloadingByOutpoint: newDownloading
});
};
@ -3990,36 +4004,6 @@ reducers$2[FILE_DELETE] = (state, action) => {
});
};
reducers$2[LOADING_VIDEO_STARTED] = (state, action) => {
const { uri } = action.data;
const newLoading = Object.assign({}, state.urisLoading);
newLoading[uri] = true;
const newErrors = _extends$8({}, state.errors);
if (uri in newErrors) delete newErrors[uri];
return Object.assign({}, state, {
urisLoading: newLoading,
errors: _extends$8({}, newErrors)
});
};
reducers$2[LOADING_VIDEO_FAILED] = (state, action) => {
const { uri } = action.data;
const newLoading = Object.assign({}, state.urisLoading);
delete newLoading[uri];
const newErrors = _extends$8({}, state.errors);
newErrors[uri] = true;
return Object.assign({}, state, {
urisLoading: newLoading,
errors: _extends$8({}, newErrors)
});
};
reducers$2[SET_FILE_LIST_SORT] = (state, action) => {
const pageSortStates = {
[PUBLISHED]: 'fileListPublishedSort',
@ -4039,7 +4023,7 @@ function fileInfoReducer(state = defaultState$3, action) {
return state;
}
var _extends$9 = 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$8 = 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 = {
@ -4055,7 +4039,7 @@ reducers$3[PURCHASE_URI_STARTED] = (state, action) => {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
}
return _extends$9({}, state, {
return _extends$8({}, state, {
failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: ''
});
@ -4073,7 +4057,7 @@ reducers$3[PURCHASE_URI_COMPLETED] = (state, action) => {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
}
return _extends$9({}, state, {
return _extends$8({}, state, {
failedPurchaseUris: newFailedPurchaseUris,
purchasedUris: newPurchasedUris,
purchaseUriErrorMessage: ''
@ -4088,7 +4072,7 @@ reducers$3[PURCHASE_URI_FAILED] = (state, action) => {
newFailedPurchaseUris.push(uri);
}
return _extends$9({}, state, {
return _extends$8({}, state, {
failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: error
});
@ -4101,7 +4085,7 @@ reducers$3[DELETE_PURCHASED_URI] = (state, action) => {
newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1);
}
return _extends$9({}, state, {
return _extends$8({}, state, {
purchasedUris: newPurchasedUris
});
};
@ -4112,7 +4096,7 @@ function fileReducer(state = defaultState$4, action) {
return state;
}
var _extends$a = 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$9 = 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: [],
@ -4127,7 +4111,7 @@ const notificationsReducer = handleActions({
const newToasts = state.toasts.slice();
newToasts.push(toast);
return _extends$a({}, state, {
return _extends$9({}, state, {
toasts: newToasts
});
},
@ -4135,7 +4119,7 @@ const notificationsReducer = handleActions({
const newToasts = state.toasts.slice();
newToasts.shift();
return _extends$a({}, state, {
return _extends$9({}, state, {
toasts: newToasts
});
},
@ -4146,7 +4130,7 @@ const notificationsReducer = handleActions({
const newNotifications = state.notifications.slice();
newNotifications.push(notification);
return _extends$a({}, state, {
return _extends$9({}, state, {
notifications: newNotifications
});
},
@ -4157,7 +4141,7 @@ const notificationsReducer = handleActions({
notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification);
return _extends$a({}, state, {
return _extends$9({}, state, {
notifications
});
},
@ -4166,7 +4150,7 @@ const notificationsReducer = handleActions({
let newNotifications = state.notifications.slice();
newNotifications = newNotifications.filter(notification => notification.id !== id);
return _extends$a({}, state, {
return _extends$9({}, state, {
notifications: newNotifications
});
},
@ -4177,7 +4161,7 @@ const notificationsReducer = handleActions({
const newErrors = state.errors.slice();
newErrors.push(error);
return _extends$a({}, state, {
return _extends$9({}, state, {
errors: newErrors
});
},
@ -4185,13 +4169,13 @@ const notificationsReducer = handleActions({
const newErrors = state.errors.slice();
newErrors.shift();
return _extends$a({}, state, {
return _extends$9({}, state, {
errors: newErrors
});
}
}, defaultState$5);
var _extends$b = 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$a = 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$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; }
@ -4228,17 +4212,17 @@ const defaultState$6 = {
const publishReducer = handleActions({
[UPDATE_PUBLISH_FORM]: (state, action) => {
const { data } = action;
return _extends$b({}, state, data);
return _extends$a({}, state, data);
},
[CLEAR_PUBLISH]: () => _extends$b({}, defaultState$6),
[PUBLISH_START]: state => _extends$b({}, state, {
[CLEAR_PUBLISH]: () => _extends$a({}, defaultState$6),
[PUBLISH_START]: state => _extends$a({}, state, {
publishing: true,
publishSuccess: false
}),
[PUBLISH_FAIL]: state => _extends$b({}, state, {
[PUBLISH_FAIL]: state => _extends$a({}, state, {
publishing: false
}),
[PUBLISH_SUCCESS]: state => _extends$b({}, state, {
[PUBLISH_SUCCESS]: state => _extends$a({}, state, {
publishing: false,
publishSuccess: true
}),
@ -4253,14 +4237,14 @@ const publishReducer = handleActions({
contentName: name
});
return _extends$b({}, defaultState$6, publishData, {
return _extends$a({}, defaultState$6, publishData, {
editingURI: uri,
uri: shortUri
});
}
}, defaultState$6);
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$b = 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 = {
isActive: false, // does the user have any typed text in the search input
@ -4280,29 +4264,29 @@ const defaultState$7 = {
};
const searchReducer = handleActions({
[SEARCH_START]: state => _extends$c({}, state, {
[SEARCH_START]: state => _extends$b({}, state, {
searching: true
}),
[SEARCH_SUCCESS]: (state, action) => {
const { query, uris } = action.data;
return _extends$c({}, state, {
return _extends$b({}, state, {
searching: false,
urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris })
});
},
[SEARCH_FAIL]: state => _extends$c({}, state, {
[SEARCH_FAIL]: state => _extends$b({}, state, {
searching: false
}),
[UPDATE_SEARCH_QUERY]: (state, action) => _extends$c({}, state, {
[UPDATE_SEARCH_QUERY]: (state, action) => _extends$b({}, state, {
searchQuery: action.data.query,
isActive: true
}),
[UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$c({}, state, {
suggestions: _extends$c({}, state.suggestions, {
[UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$b({}, state, {
suggestions: _extends$b({}, state.suggestions, {
[action.data.query]: action.data.suggestions
})
}),
@ -4310,30 +4294,30 @@ const searchReducer = handleActions({
// 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
// other page
[DISMISS_NOTIFICATION]: state => _extends$c({}, state, {
[DISMISS_NOTIFICATION]: state => _extends$b({}, state, {
isActive: false
}),
[SEARCH_FOCUS]: state => _extends$c({}, state, {
[SEARCH_FOCUS]: state => _extends$b({}, state, {
focused: true
}),
[SEARCH_BLUR]: state => _extends$c({}, state, {
[SEARCH_BLUR]: state => _extends$b({}, state, {
focused: false
}),
[UPDATE_SEARCH_OPTIONS]: (state, action) => {
const { options: oldOptions } = state;
const newOptions = action.data;
const options = _extends$c({}, oldOptions, newOptions);
return _extends$c({}, state, {
const options = _extends$b({}, oldOptions, newOptions);
return _extends$b({}, state, {
options
});
}
}, defaultState$7);
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; };
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; };
function getDefaultKnownTags() {
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => _extends$d({}, tagsMap, {
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => _extends$c({}, tagsMap, {
[tag]: { name: tag }
}), {});
}
@ -4356,7 +4340,7 @@ const tagsReducer = handleActions({
newFollowedTags.push(name);
}
return _extends$d({}, state, {
return _extends$c({}, state, {
followedTags: newFollowedTags
});
},
@ -4365,10 +4349,10 @@ const tagsReducer = handleActions({
const { knownTags } = state;
const { name } = action.data;
let newKnownTags = _extends$d({}, knownTags);
let newKnownTags = _extends$c({}, knownTags);
newKnownTags[name] = { name };
return _extends$d({}, state, {
return _extends$c({}, state, {
knownTags: newKnownTags
});
},
@ -4377,11 +4361,11 @@ const tagsReducer = handleActions({
const { knownTags, followedTags } = state;
const { name } = action.data;
let newKnownTags = _extends$d({}, knownTags);
let newKnownTags = _extends$c({}, knownTags);
delete newKnownTags[name];
const newFollowedTags = followedTags.filter(tag => tag !== name);
return _extends$d({}, state, {
return _extends$c({}, state, {
knownTags: newKnownTags,
followedTags: newFollowedTags
});
@ -4412,7 +4396,7 @@ const blockedReducer = handleActions({
}
}, defaultState$9);
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; };
const buildDraftTransaction = () => ({
amount: undefined,
@ -4452,25 +4436,25 @@ const defaultState$a = {
};
const walletReducer = handleActions({
[FETCH_TRANSACTIONS_STARTED]: state => _extends$e({}, state, {
[FETCH_TRANSACTIONS_STARTED]: state => _extends$d({}, state, {
fetchingTransactions: true
}),
[FETCH_TRANSACTIONS_COMPLETED]: (state, action) => {
const byId = _extends$e({}, state.transactions);
const byId = _extends$d({}, state.transactions);
const { transactions } = action.data;
transactions.forEach(transaction => {
byId[transaction.txid] = transaction;
});
return _extends$e({}, state, {
return _extends$d({}, state, {
transactions: byId,
fetchingTransactions: false
});
},
[FETCH_SUPPORTS_STARTED]: state => _extends$e({}, state, {
[FETCH_SUPPORTS_STARTED]: state => _extends$d({}, state, {
fetchingSupports: true
}),
@ -4483,7 +4467,7 @@ const walletReducer = handleActions({
byOutpoint[`${txid}:${nout}`] = transaction;
});
return _extends$e({}, state, { supports: byOutpoint, fetchingSupports: false });
return _extends$d({}, state, { supports: byOutpoint, fetchingSupports: false });
},
[ABANDON_SUPPORT_STARTED]: (state, action) => {
@ -4492,7 +4476,7 @@ const walletReducer = handleActions({
currentlyAbandoning[outpoint] = true;
return _extends$e({}, state, {
return _extends$d({}, state, {
abandoningSupportsByOutpoint: currentlyAbandoning
});
},
@ -4505,56 +4489,56 @@ const walletReducer = handleActions({
delete currentlyAbandoning[outpoint];
delete byOutpoint[outpoint];
return _extends$e({}, state, {
return _extends$d({}, state, {
supports: byOutpoint,
abandoningSupportsById: currentlyAbandoning
});
},
[GET_NEW_ADDRESS_STARTED]: state => _extends$e({}, state, {
[GET_NEW_ADDRESS_STARTED]: state => _extends$d({}, state, {
gettingNewAddress: true
}),
[GET_NEW_ADDRESS_COMPLETED]: (state, action) => {
const { address } = action.data;
return _extends$e({}, state, { gettingNewAddress: false, receiveAddress: address });
return _extends$d({}, state, { gettingNewAddress: false, receiveAddress: address });
},
[UPDATE_BALANCE]: (state, action) => _extends$e({}, state, {
[UPDATE_BALANCE]: (state, action) => _extends$d({}, state, {
balance: action.data.balance
}),
[UPDATE_TOTAL_BALANCE]: (state, action) => _extends$e({}, state, {
[UPDATE_TOTAL_BALANCE]: (state, action) => _extends$d({}, state, {
totalBalance: action.data.totalBalance
}),
[CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$e({}, state, {
[CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$d({}, state, {
checkingAddressOwnership: true
}),
[CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$e({}, state, {
[CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$d({}, state, {
checkingAddressOwnership: false
}),
[SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => {
const oldDraft = state.draftTransaction;
const newDraft = _extends$e({}, oldDraft, { amount: parseFloat(action.data.amount) });
const newDraft = _extends$d({}, oldDraft, { amount: parseFloat(action.data.amount) });
return _extends$e({}, state, { draftTransaction: newDraft });
return _extends$d({}, state, { draftTransaction: newDraft });
},
[SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => {
const oldDraft = state.draftTransaction;
const newDraft = _extends$e({}, oldDraft, { address: action.data.address });
const newDraft = _extends$d({}, oldDraft, { address: action.data.address });
return _extends$e({}, state, { draftTransaction: newDraft });
return _extends$d({}, state, { draftTransaction: newDraft });
},
[SEND_TRANSACTION_STARTED]: state => {
const newDraftTransaction = _extends$e({}, state.draftTransaction, { sending: true });
const newDraftTransaction = _extends$d({}, state.draftTransaction, { sending: true });
return _extends$e({}, state, { draftTransaction: newDraftTransaction });
return _extends$d({}, state, { draftTransaction: newDraftTransaction });
},
[SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, {
@ -4567,103 +4551,103 @@ const walletReducer = handleActions({
error: action.data.error
});
return _extends$e({}, state, { draftTransaction: newDraftTransaction });
return _extends$d({}, state, { draftTransaction: newDraftTransaction });
},
[SUPPORT_TRANSACTION_STARTED]: state => _extends$e({}, state, {
[SUPPORT_TRANSACTION_STARTED]: state => _extends$d({}, state, {
sendingSupport: true
}),
[SUPPORT_TRANSACTION_COMPLETED]: state => _extends$e({}, state, {
[SUPPORT_TRANSACTION_COMPLETED]: state => _extends$d({}, state, {
sendingSupport: false
}),
[SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$e({}, state, {
[SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$d({}, state, {
error: action.data.error,
sendingSupport: false
}),
[WALLET_STATUS_COMPLETED]: (state, action) => _extends$e({}, state, {
[WALLET_STATUS_COMPLETED]: (state, action) => _extends$d({}, state, {
walletIsEncrypted: action.result
}),
[WALLET_ENCRYPT_START]: state => _extends$e({}, state, {
[WALLET_ENCRYPT_START]: state => _extends$d({}, state, {
walletEncryptPending: true,
walletEncryptSucceded: null,
walletEncryptResult: null
}),
[WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$e({}, state, {
[WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$d({}, state, {
walletEncryptPending: false,
walletEncryptSucceded: true,
walletEncryptResult: action.result
}),
[WALLET_ENCRYPT_FAILED]: (state, action) => _extends$e({}, state, {
[WALLET_ENCRYPT_FAILED]: (state, action) => _extends$d({}, state, {
walletEncryptPending: false,
walletEncryptSucceded: false,
walletEncryptResult: action.result
}),
[WALLET_DECRYPT_START]: state => _extends$e({}, state, {
[WALLET_DECRYPT_START]: state => _extends$d({}, state, {
walletDecryptPending: true,
walletDecryptSucceded: null,
walletDecryptResult: null
}),
[WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$e({}, state, {
[WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$d({}, state, {
walletDecryptPending: false,
walletDecryptSucceded: true,
walletDecryptResult: action.result
}),
[WALLET_DECRYPT_FAILED]: (state, action) => _extends$e({}, state, {
[WALLET_DECRYPT_FAILED]: (state, action) => _extends$d({}, state, {
walletDecryptPending: false,
walletDecryptSucceded: false,
walletDecryptResult: action.result
}),
[WALLET_UNLOCK_START]: state => _extends$e({}, state, {
[WALLET_UNLOCK_START]: state => _extends$d({}, state, {
walletUnlockPending: true,
walletUnlockSucceded: null,
walletUnlockResult: null
}),
[WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$e({}, state, {
[WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$d({}, state, {
walletUnlockPending: false,
walletUnlockSucceded: true,
walletUnlockResult: action.result
}),
[WALLET_UNLOCK_FAILED]: (state, action) => _extends$e({}, state, {
[WALLET_UNLOCK_FAILED]: (state, action) => _extends$d({}, state, {
walletUnlockPending: false,
walletUnlockSucceded: false,
walletUnlockResult: action.result
}),
[WALLET_LOCK_START]: state => _extends$e({}, state, {
[WALLET_LOCK_START]: state => _extends$d({}, state, {
walletLockPending: false,
walletLockSucceded: null,
walletLockResult: null
}),
[WALLET_LOCK_COMPLETED]: (state, action) => _extends$e({}, state, {
[WALLET_LOCK_COMPLETED]: (state, action) => _extends$d({}, state, {
walletLockPending: false,
walletLockSucceded: true,
walletLockResult: action.result
}),
[WALLET_LOCK_FAILED]: (state, action) => _extends$e({}, state, {
[WALLET_LOCK_FAILED]: (state, action) => _extends$d({}, state, {
walletLockPending: false,
walletLockSucceded: false,
walletLockResult: action.result
}),
[SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$e({}, state, {
[SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$d({}, state, {
transactionListFilter: action.data
}),
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$e({}, state, {
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$d({}, state, {
latestBlock: action.data
})
}, defaultState$a);
@ -4679,14 +4663,14 @@ const makeSelectContentPositionForUri = uri => reselect.createSelector(selectSta
return state.positions[id] ? state.positions[id][outpoint] : null;
});
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 selectState$7 = state => state.notifications || {};
const selectToast = reselect.createSelector(selectState$7, state => {
if (state.toasts.length) {
const { id, params } = state.toasts[0];
return _extends$f({
return _extends$e({
id
}, params);
}

View file

@ -111,6 +111,7 @@ export const FILE_LIST_STARTED = 'FILE_LIST_STARTED';
export const FILE_LIST_SUCCEEDED = 'FILE_LIST_SUCCEEDED';
export const FETCH_FILE_INFO_STARTED = 'FETCH_FILE_INFO_STARTED';
export const FETCH_FILE_INFO_COMPLETED = 'FETCH_FILE_INFO_COMPLETED';
export const FETCH_FILE_INFO_FAILED = 'FETCH_FILE_INFO_FAILED';
export const LOADING_VIDEO_STARTED = 'LOADING_VIDEO_STARTED';
export const LOADING_VIDEO_COMPLETED = 'LOADING_VIDEO_COMPLETED';
export const LOADING_VIDEO_FAILED = 'LOADING_VIDEO_FAILED';

View file

@ -5,16 +5,21 @@ import { doToast } from 'redux/actions/notifications';
import { selectBalance } from 'redux/selectors/wallet';
import { makeSelectFileInfoForUri, selectDownloadingByOutpoint } from 'redux/selectors/file_info';
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
type Dispatch = (action: any) => any;
type GetState = () => { file: FileState };
export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: GetResponse => any) {
return (dispatch: Dispatch) => {
return (dispatch: Dispatch, getState: () => any) => {
const state = getState();
const { nout, txid } = makeSelectClaimForUri(uri)(state);
const outpoint = `${txid}:${nout}`;
dispatch({
type: ACTIONS.PURCHASE_URI_STARTED,
type: ACTIONS.FETCH_FILE_INFO_STARTED,
data: {
uri,
outpoint,
},
});
@ -26,8 +31,8 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
if (timeout) {
dispatch({
type: ACTIONS.PURCHASE_URI_FAILED,
data: { uri },
type: ACTIONS.FETCH_FILE_INFO_FAILED,
data: { outpoint },
});
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
@ -56,6 +61,11 @@ export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: Get
data: { uri },
});
dispatch({
type: ACTIONS.FETCH_FILE_INFO_FAILED,
data: { outpoint },
});
dispatch(
doToast({
message: `Failed to view ${uri}, please try again. If this problem persists, visit https://lbry.com/faq/support for support.`,

View file

@ -57,20 +57,27 @@ reducers[ACTIONS.FETCH_FILE_INFO_COMPLETED] = (state, action) => {
});
};
reducers[ACTIONS.FETCH_FILE_INFO_FAILED] = (state, action) => {
const { outpoint } = action.data;
const newFetching = Object.assign({}, state.fetching);
delete newFetching[outpoint];
return Object.assign({}, state, {
fetching: newFetching,
});
};
reducers[ACTIONS.DOWNLOADING_STARTED] = (state, action) => {
const { uri, outpoint, fileInfo } = action.data;
const newByOutpoint = Object.assign({}, state.byOutpoint);
const newDownloading = Object.assign({}, state.downloadingByOutpoint);
const newLoading = Object.assign({}, state.urisLoading);
newDownloading[outpoint] = true;
newByOutpoint[outpoint] = fileInfo;
delete newLoading[uri];
return Object.assign({}, state, {
downloadingByOutpoint: newDownloading,
urisLoading: newLoading,
byOutpoint: newByOutpoint,
});
};
@ -95,11 +102,9 @@ reducers[ACTIONS.DOWNLOADING_CANCELED] = (state, action) => {
const newDownloading = Object.assign({}, state.downloadingByOutpoint);
delete newDownloading[outpoint];
delete newLoading[uri];
return Object.assign({}, state, {
downloadingByOutpoint: newDownloading,
urisLoading: newLoading,
});
};
@ -133,36 +138,6 @@ reducers[ACTIONS.FILE_DELETE] = (state, action) => {
});
};
reducers[ACTIONS.LOADING_VIDEO_STARTED] = (state, action) => {
const { uri } = action.data;
const newLoading = Object.assign({}, state.urisLoading);
newLoading[uri] = true;
const newErrors = { ...state.errors };
if (uri in newErrors) delete newErrors[uri];
return Object.assign({}, state, {
urisLoading: newLoading,
errors: { ...newErrors },
});
};
reducers[ACTIONS.LOADING_VIDEO_FAILED] = (state, action) => {
const { uri } = action.data;
const newLoading = Object.assign({}, state.urisLoading);
delete newLoading[uri];
const newErrors = { ...state.errors };
newErrors[uri] = true;
return Object.assign({}, state, {
urisLoading: newLoading,
errors: { ...newErrors },
});
};
reducers[ACTIONS.SET_FILE_LIST_SORT] = (state, action) => {
const pageSortStates = {
[PAGES.PUBLISHED]: 'fileListPublishedSort',