redux housekeeping for yt import pending and errors
This commit is contained in:
parent
1890985bec
commit
34b91fca23
6 changed files with 173 additions and 36 deletions
50
dist/bundle.es.js
vendored
50
dist/bundle.es.js
vendored
|
@ -994,6 +994,8 @@ const selectUserInviteStatusFailed = reselect.createSelector(selectUserInvitesRe
|
|||
const selectUserInviteNewIsPending = reselect.createSelector(selectState$2, state => state.inviteNewIsPending);
|
||||
const selectUserInviteNewErrorMessage = reselect.createSelector(selectState$2, state => state.inviteNewErrorMessage);
|
||||
const selectUserInviteReferralLink = reselect.createSelector(selectState$2, state => state.referralLink);
|
||||
const selectYTImportPending = reselect.createSelector(selectState$2, state => state.ytChannelImportPending);
|
||||
const selectYTImportError = reselect.createSelector(selectState$2, state => state.ytChannelImportErrorMessage);
|
||||
|
||||
function doFetchInviteStatus() {
|
||||
return dispatch => {
|
||||
|
@ -1367,11 +1369,14 @@ function doUserInviteNew(email) {
|
|||
}
|
||||
function doClaimYoutubeChannels() {
|
||||
return dispatch => {
|
||||
lbryRedux.Lbry.address_unused().then(address => // add dispatch started here
|
||||
Lbryio.call('yt', 'transfer', {
|
||||
address
|
||||
dispatch({
|
||||
type: lbryRedux.ACTIONS.USER_YOUTUBE_IMPORT_STARTED
|
||||
});
|
||||
lbryRedux.Lbry.address_list().then(addressList => addressList.find(el => el.used_times === 0)).then(address => Lbryio.call('yt', 'transfer', {
|
||||
address: address.address,
|
||||
public_key: address.public_key
|
||||
}).then(response => {
|
||||
if (response && response.length) {
|
||||
if (response && response.success) {
|
||||
Promise.all(response.map(channelMeta => {
|
||||
if (channelMeta && channelMeta.channel && channelMeta.channel.transferable) {
|
||||
return lbryRedux.Lbry.channel_import({
|
||||
|
@ -1380,9 +1385,21 @@ function doClaimYoutubeChannels() {
|
|||
}
|
||||
|
||||
return null;
|
||||
})).then(() => dispatch(doUserFetch())); // update the channel data the form uses
|
||||
})).then(() => {
|
||||
const actions = [{
|
||||
type: lbryRedux.ACTIONS.USER_YOUTUBE_IMPORT_COMPLETED
|
||||
}];
|
||||
actions.push(doUserFetch());
|
||||
actions.push(lbryRedux.doFetchChannelListMine());
|
||||
dispatch(lbryRedux.batchActions(...actions));
|
||||
});
|
||||
}
|
||||
})).catch(e => console.error('Transfering channels failed', e));
|
||||
})).catch(error => {
|
||||
dispatch({
|
||||
type: lbryRedux.ACTIONS.USER_YOUTUBE_IMPORT_FAILURE,
|
||||
data: String(error)
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2475,7 +2492,9 @@ const defaultState$3 = {
|
|||
inviteStatusIsPending: false,
|
||||
invitesRemaining: undefined,
|
||||
invitees: undefined,
|
||||
user: undefined
|
||||
user: undefined,
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: ''
|
||||
};
|
||||
|
||||
reducers$2[lbryRedux.ACTIONS.AUTHENTICATION_STARTED] = state => Object.assign({}, state, {
|
||||
|
@ -2657,6 +2676,21 @@ reducers$2[lbryRedux.ACTIONS.USER_INVITE_STATUS_FETCH_FAILURE] = state => Object
|
|||
invitees: null
|
||||
});
|
||||
|
||||
reducers$2[lbryRedux.ACTIONS.USER_YOUTUBE_IMPORT_STARTED] = state => Object.assign({}, state, {
|
||||
ytChannelImportPending: true,
|
||||
ytChannelImportErrorMessage: ''
|
||||
});
|
||||
|
||||
reducers$2[lbryRedux.ACTIONS.USER_YOUTUBE_IMPORT_COMPLETED] = state => Object.assign({}, state, {
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: ''
|
||||
});
|
||||
|
||||
reducers$2[lbryRedux.ACTIONS.USER_YOUTUBE_IMPORT_FAILURE] = (state, action) => Object.assign({}, state, {
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: action.data
|
||||
});
|
||||
|
||||
function userReducer(state = defaultState$3, action) {
|
||||
const handler = reducers$2[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
|
@ -3068,6 +3102,8 @@ exports.selectUserIsVerificationCandidate = selectUserIsVerificationCandidate;
|
|||
exports.selectUserPhone = selectUserPhone;
|
||||
exports.selectUserVerifiedEmail = selectUserVerifiedEmail;
|
||||
exports.selectViewMode = selectViewMode;
|
||||
exports.selectYTImportError = selectYTImportError;
|
||||
exports.selectYTImportPending = selectYTImportPending;
|
||||
exports.selectYoutubeChannels = selectYoutubeChannels;
|
||||
exports.setSubscriptionLatest = setSubscriptionLatest;
|
||||
exports.statsReducer = statsReducer;
|
||||
|
|
73
dist/bundle.js
vendored
73
dist/bundle.js
vendored
|
@ -385,6 +385,10 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectYoutubeChannels", function() { return redux_selectors_user__WEBPACK_IMPORTED_MODULE_27__["selectYoutubeChannels"]; });
|
||||
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectYTImportPending", function() { return redux_selectors_user__WEBPACK_IMPORTED_MODULE_27__["selectYTImportPending"]; });
|
||||
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectYTImportError", function() { return redux_selectors_user__WEBPACK_IMPORTED_MODULE_27__["selectYTImportError"]; });
|
||||
|
||||
/* harmony import */ var redux_selectors_cost_info__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(38);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeSelectFetchingCostInfoForUri", function() { return redux_selectors_cost_info__WEBPACK_IMPORTED_MODULE_28__["makeSelectFetchingCostInfoForUri"]; });
|
||||
|
||||
|
@ -2287,6 +2291,8 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectUserInviteNewIsPending", function() { return selectUserInviteNewIsPending; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectUserInviteNewErrorMessage", function() { return selectUserInviteNewErrorMessage; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectUserInviteReferralLink", function() { return selectUserInviteReferralLink; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectYTImportPending", function() { return selectYTImportPending; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectYTImportError", function() { return selectYTImportError; });
|
||||
/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
|
||||
/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reselect__WEBPACK_IMPORTED_MODULE_0__);
|
||||
|
||||
|
@ -2383,6 +2389,12 @@ var selectUserInviteNewErrorMessage = Object(reselect__WEBPACK_IMPORTED_MODULE_0
|
|||
var selectUserInviteReferralLink = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) {
|
||||
return state.referralLink;
|
||||
});
|
||||
var selectYTImportPending = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) {
|
||||
return state.ytChannelImportPending;
|
||||
});
|
||||
var selectYTImportError = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) {
|
||||
return state.ytChannelImportErrorMessage;
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
/* 19 */
|
||||
|
@ -2811,12 +2823,19 @@ function doUserInviteNew(email) {
|
|||
}
|
||||
function doClaimYoutubeChannels() {
|
||||
return function (dispatch) {
|
||||
lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].address_unused().then(function (address) {
|
||||
return (// add dispatch started here
|
||||
lbryio__WEBPACK_IMPORTED_MODULE_4__["default"].call('yt', 'transfer', {
|
||||
address: address
|
||||
dispatch({
|
||||
type: lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_YOUTUBE_IMPORT_STARTED
|
||||
});
|
||||
lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].address_list().then(function (addressList) {
|
||||
return addressList.find(function (el) {
|
||||
return el.used_times === 0;
|
||||
});
|
||||
}).then(function (address) {
|
||||
return lbryio__WEBPACK_IMPORTED_MODULE_4__["default"].call('yt', 'transfer', {
|
||||
address: address.address,
|
||||
public_key: address.public_key
|
||||
}).then(function (response) {
|
||||
if (response && response.length) {
|
||||
if (response && response.success) {
|
||||
Promise.all(response.map(function (channelMeta) {
|
||||
if (channelMeta && channelMeta.channel && channelMeta.channel.transferable) {
|
||||
return lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].channel_import({
|
||||
|
@ -2826,13 +2845,20 @@ function doClaimYoutubeChannels() {
|
|||
|
||||
return null;
|
||||
})).then(function () {
|
||||
return dispatch(doUserFetch());
|
||||
}); // update the channel data the form uses
|
||||
var actions = [{
|
||||
type: lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_YOUTUBE_IMPORT_COMPLETED
|
||||
}];
|
||||
actions.push(doUserFetch());
|
||||
actions.push(Object(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["doFetchChannelListMine"])());
|
||||
dispatch(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["batchActions"].apply(void 0, actions));
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
})["catch"](function (e) {
|
||||
return console.error('Transfering channels failed', e);
|
||||
});
|
||||
})["catch"](function (error) {
|
||||
dispatch({
|
||||
type: lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_YOUTUBE_IMPORT_FAILURE,
|
||||
data: String(error)
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -4050,7 +4076,9 @@ var defaultState = {
|
|||
inviteStatusIsPending: false,
|
||||
invitesRemaining: undefined,
|
||||
invitees: undefined,
|
||||
user: undefined
|
||||
user: undefined,
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: ''
|
||||
};
|
||||
|
||||
reducers[lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].AUTHENTICATION_STARTED] = function (state) {
|
||||
|
@ -4284,6 +4312,27 @@ reducers[lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_INVITE_STATUS_F
|
|||
});
|
||||
};
|
||||
|
||||
reducers[lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_YOUTUBE_IMPORT_STARTED] = function (state) {
|
||||
return Object.assign({}, state, {
|
||||
ytChannelImportPending: true,
|
||||
ytChannelImportErrorMessage: ''
|
||||
});
|
||||
};
|
||||
|
||||
reducers[lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_YOUTUBE_IMPORT_COMPLETED] = function (state) {
|
||||
return Object.assign({}, state, {
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: ''
|
||||
});
|
||||
};
|
||||
|
||||
reducers[lbry_redux__WEBPACK_IMPORTED_MODULE_0__["ACTIONS"].USER_YOUTUBE_IMPORT_FAILURE] = function (state, action) {
|
||||
return Object.assign({}, state, {
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: action.data
|
||||
});
|
||||
};
|
||||
|
||||
function userReducer() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
|
|
@ -153,6 +153,8 @@ export {
|
|||
selectUserInviteReferralLink,
|
||||
selectUserVerifiedEmail,
|
||||
selectYoutubeChannels,
|
||||
selectYTImportPending,
|
||||
selectYTImportError,
|
||||
} from 'redux/selectors/user';
|
||||
export {
|
||||
makeSelectFetchingCostInfoForUri,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ACTIONS, Lbry, doToast } from 'lbry-redux';
|
||||
import { ACTIONS, Lbry, doToast, doFetchChannelListMine, batchActions } from 'lbry-redux';
|
||||
import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
|
||||
import {
|
||||
selectEmailToVerify,
|
||||
|
@ -385,11 +385,17 @@ export function doUserInviteNew(email) {
|
|||
|
||||
export function doClaimYoutubeChannels() {
|
||||
return dispatch => {
|
||||
Lbry.address_unused()
|
||||
dispatch({
|
||||
type: ACTIONS.USER_YOUTUBE_IMPORT_STARTED,
|
||||
});
|
||||
Lbry.address_list()
|
||||
.then(addressList => addressList.find(el => el.used_times === 0))
|
||||
.then(address =>
|
||||
// add dispatch started here
|
||||
Lbryio.call('yt', 'transfer', { address }).then(response => {
|
||||
if (response && response.length) {
|
||||
Lbryio.call('yt', 'transfer', {
|
||||
address: address.address,
|
||||
public_key: address.public_key,
|
||||
}).then(response => {
|
||||
if (response && response.success) {
|
||||
Promise.all(
|
||||
response.map(channelMeta => {
|
||||
if (channelMeta && channelMeta.channel && channelMeta.channel.transferable) {
|
||||
|
@ -399,10 +405,24 @@ export function doClaimYoutubeChannels() {
|
|||
}
|
||||
return null;
|
||||
})
|
||||
).then(() => dispatch(doUserFetch())); // update the channel data the form uses
|
||||
).then(() => {
|
||||
const actions = [
|
||||
{
|
||||
type: ACTIONS.USER_YOUTUBE_IMPORT_COMPLETED,
|
||||
},
|
||||
];
|
||||
actions.push(doUserFetch());
|
||||
actions.push(doFetchChannelListMine());
|
||||
dispatch(batchActions(...actions));
|
||||
});
|
||||
}
|
||||
})
|
||||
)
|
||||
.catch(e => console.error('Transfering channels failed', e));
|
||||
.catch(error => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_YOUTUBE_IMPORT_FAILURE,
|
||||
data: String(error),
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ const defaultState = {
|
|||
invitesRemaining: undefined,
|
||||
invitees: undefined,
|
||||
user: undefined,
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: '',
|
||||
};
|
||||
|
||||
reducers[ACTIONS.AUTHENTICATION_STARTED] = state =>
|
||||
|
@ -221,6 +223,24 @@ reducers[ACTIONS.USER_INVITE_STATUS_FETCH_FAILURE] = state =>
|
|||
invitees: null,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.USER_YOUTUBE_IMPORT_STARTED] = state =>
|
||||
Object.assign({}, state, {
|
||||
ytChannelImportPending: true,
|
||||
ytChannelImportErrorMessage: '',
|
||||
});
|
||||
|
||||
reducers[ACTIONS.USER_YOUTUBE_IMPORT_COMPLETED] = state =>
|
||||
Object.assign({}, state, {
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: '',
|
||||
});
|
||||
|
||||
reducers[ACTIONS.USER_YOUTUBE_IMPORT_FAILURE] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
ytChannelImportPending: false,
|
||||
ytChannelImportErrorMessage: action.data,
|
||||
});
|
||||
|
||||
export function userReducer(state = defaultState, action) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
|
|
|
@ -141,3 +141,13 @@ export const selectUserInviteReferralLink = createSelector(
|
|||
selectState,
|
||||
state => state.referralLink
|
||||
);
|
||||
|
||||
export const selectYTImportPending = createSelector(
|
||||
selectState,
|
||||
state => state.ytChannelImportPending
|
||||
);
|
||||
|
||||
export const selectYTImportError = createSelector(
|
||||
selectState,
|
||||
state => state.ytChannelImportErrorMessage
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue