commit
bd48a138c9
6 changed files with 92 additions and 27 deletions
31
dist/bundle.es.js
vendored
31
dist/bundle.es.js
vendored
|
@ -52,7 +52,8 @@ const USER_YOUTUBE_IMPORT_FAILURE = 'USER_YOUTUBE_IMPORT_FAILURE';
|
||||||
const USER_YOUTUBE_IMPORT_SUCCESS = 'USER_YOUTUBE_IMPORT_SUCCESS';
|
const USER_YOUTUBE_IMPORT_SUCCESS = 'USER_YOUTUBE_IMPORT_SUCCESS';
|
||||||
const USER_SET_REFERRER_STARTED = 'USER_SET_REFERRER_STARTED';
|
const USER_SET_REFERRER_STARTED = 'USER_SET_REFERRER_STARTED';
|
||||||
const USER_SET_REFERRER_SUCCESS = 'USER_SET_REFERRER_SUCCESS';
|
const USER_SET_REFERRER_SUCCESS = 'USER_SET_REFERRER_SUCCESS';
|
||||||
const USER_SET_REFERRER_FAILURE = 'USER_SET_REFERRER_FAILURE'; // Claims
|
const USER_SET_REFERRER_FAILURE = 'USER_SET_REFERRER_FAILURE';
|
||||||
|
const USER_SET_REFERRER_RESET = 'USER_SET_REFERRER_RESET'; // Claims
|
||||||
|
|
||||||
const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
||||||
const FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED';
|
const FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED';
|
||||||
|
@ -182,6 +183,7 @@ var action_types = /*#__PURE__*/Object.freeze({
|
||||||
USER_SET_REFERRER_STARTED: USER_SET_REFERRER_STARTED,
|
USER_SET_REFERRER_STARTED: USER_SET_REFERRER_STARTED,
|
||||||
USER_SET_REFERRER_SUCCESS: USER_SET_REFERRER_SUCCESS,
|
USER_SET_REFERRER_SUCCESS: USER_SET_REFERRER_SUCCESS,
|
||||||
USER_SET_REFERRER_FAILURE: USER_SET_REFERRER_FAILURE,
|
USER_SET_REFERRER_FAILURE: USER_SET_REFERRER_FAILURE,
|
||||||
|
USER_SET_REFERRER_RESET: USER_SET_REFERRER_RESET,
|
||||||
FETCH_FEATURED_CONTENT_STARTED: FETCH_FEATURED_CONTENT_STARTED,
|
FETCH_FEATURED_CONTENT_STARTED: FETCH_FEATURED_CONTENT_STARTED,
|
||||||
FETCH_FEATURED_CONTENT_COMPLETED: FETCH_FEATURED_CONTENT_COMPLETED,
|
FETCH_FEATURED_CONTENT_COMPLETED: FETCH_FEATURED_CONTENT_COMPLETED,
|
||||||
FETCH_TRENDING_CONTENT_STARTED: FETCH_TRENDING_CONTENT_STARTED,
|
FETCH_TRENDING_CONTENT_STARTED: FETCH_TRENDING_CONTENT_STARTED,
|
||||||
|
@ -1623,16 +1625,25 @@ function doUserInviteNew(email) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function doUserSetReferrerReset() {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch({
|
||||||
|
type: USER_SET_REFERRER_RESET
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
function doUserSetReferrer(referrer, shouldClaim) {
|
function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: USER_SET_REFERRER_STARTED
|
type: USER_SET_REFERRER_STARTED
|
||||||
});
|
});
|
||||||
let claim;
|
let claim;
|
||||||
let referrerCode = referrer;
|
let referrerCode;
|
||||||
const isClaim = lbryRedux.parseURI(referrer).claimId;
|
const {
|
||||||
|
isChannel
|
||||||
|
} = lbryRedux.parseURI(referrer);
|
||||||
|
|
||||||
if (isClaim) {
|
if (isChannel) {
|
||||||
const uri = `lbry://${referrer}`;
|
const uri = `lbry://${referrer}`;
|
||||||
claim = lbryRedux.makeSelectClaimForUri(uri)(getState());
|
claim = lbryRedux.makeSelectClaimForUri(uri)(getState());
|
||||||
|
|
||||||
|
@ -1652,7 +1663,11 @@ function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
referrerCode = claim && claim.permanent_url.replace('lbry://', '');
|
referrerCode = claim && claim.permanent_url && claim.permanent_url.replace('lbry://', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!referrerCode) {
|
||||||
|
referrerCode = referrer;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -3200,6 +3215,11 @@ reducers$2[USER_SET_REFERRER_FAILURE] = (state, action) => Object.assign({}, sta
|
||||||
referrerSetError: action.data.error.message
|
referrerSetError: action.data.error.message
|
||||||
});
|
});
|
||||||
|
|
||||||
|
reducers$2[USER_SET_REFERRER_RESET] = state => Object.assign({}, state, {
|
||||||
|
referrerSetIsPending: false,
|
||||||
|
referrerSetError: defaultState$3.referrerSetError
|
||||||
|
});
|
||||||
|
|
||||||
function userReducer(state = defaultState$3, action) {
|
function userReducer(state = defaultState$3, action) {
|
||||||
const handler = reducers$2[action.type];
|
const handler = reducers$2[action.type];
|
||||||
if (handler) return handler(state, action);
|
if (handler) return handler(state, action);
|
||||||
|
@ -3634,6 +3654,7 @@ exports.doUserPhoneVerify = doUserPhoneVerify;
|
||||||
exports.doUserPhoneVerifyFailure = doUserPhoneVerifyFailure;
|
exports.doUserPhoneVerifyFailure = doUserPhoneVerifyFailure;
|
||||||
exports.doUserResendVerificationEmail = doUserResendVerificationEmail;
|
exports.doUserResendVerificationEmail = doUserResendVerificationEmail;
|
||||||
exports.doUserSetReferrer = doUserSetReferrer;
|
exports.doUserSetReferrer = doUserSetReferrer;
|
||||||
|
exports.doUserSetReferrerReset = doUserSetReferrerReset;
|
||||||
exports.filteredReducer = filteredReducer;
|
exports.filteredReducer = filteredReducer;
|
||||||
exports.homepageReducer = homepageReducer;
|
exports.homepageReducer = homepageReducer;
|
||||||
exports.lbrytvReducer = lbrytvReducer;
|
exports.lbrytvReducer = lbrytvReducer;
|
||||||
|
|
59
dist/bundle.js
vendored
59
dist/bundle.js
vendored
|
@ -209,6 +209,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
|
|
||||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doUserSetReferrer", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doUserSetReferrer"]; });
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doUserSetReferrer", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doUserSetReferrer"]; });
|
||||||
|
|
||||||
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doUserSetReferrerReset", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doUserSetReferrerReset"]; });
|
||||||
|
|
||||||
/* harmony import */ var redux_actions_cost_info__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(30);
|
/* harmony import */ var redux_actions_cost_info__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(30);
|
||||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doFetchCostInfoForUri", function() { return redux_actions_cost_info__WEBPACK_IMPORTED_MODULE_12__["doFetchCostInfoForUri"]; });
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doFetchCostInfoForUri", function() { return redux_actions_cost_info__WEBPACK_IMPORTED_MODULE_12__["doFetchCostInfoForUri"]; });
|
||||||
|
|
||||||
|
@ -582,6 +584,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_STARTED", function() { return USER_SET_REFERRER_STARTED; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_STARTED", function() { return USER_SET_REFERRER_STARTED; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_SUCCESS", function() { return USER_SET_REFERRER_SUCCESS; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_SUCCESS", function() { return USER_SET_REFERRER_SUCCESS; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_FAILURE", function() { return USER_SET_REFERRER_FAILURE; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_FAILURE", function() { return USER_SET_REFERRER_FAILURE; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USER_SET_REFERRER_RESET", function() { return USER_SET_REFERRER_RESET; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FETCH_FEATURED_CONTENT_STARTED", function() { return FETCH_FEATURED_CONTENT_STARTED; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FETCH_FEATURED_CONTENT_STARTED", function() { return FETCH_FEATURED_CONTENT_STARTED; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FETCH_FEATURED_CONTENT_COMPLETED", function() { return FETCH_FEATURED_CONTENT_COMPLETED; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FETCH_FEATURED_CONTENT_COMPLETED", function() { return FETCH_FEATURED_CONTENT_COMPLETED; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FETCH_TRENDING_CONTENT_STARTED", function() { return FETCH_TRENDING_CONTENT_STARTED; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FETCH_TRENDING_CONTENT_STARTED", function() { return FETCH_TRENDING_CONTENT_STARTED; });
|
||||||
|
@ -701,7 +704,8 @@ var USER_YOUTUBE_IMPORT_FAILURE = 'USER_YOUTUBE_IMPORT_FAILURE';
|
||||||
var USER_YOUTUBE_IMPORT_SUCCESS = 'USER_YOUTUBE_IMPORT_SUCCESS';
|
var USER_YOUTUBE_IMPORT_SUCCESS = 'USER_YOUTUBE_IMPORT_SUCCESS';
|
||||||
var USER_SET_REFERRER_STARTED = 'USER_SET_REFERRER_STARTED';
|
var USER_SET_REFERRER_STARTED = 'USER_SET_REFERRER_STARTED';
|
||||||
var USER_SET_REFERRER_SUCCESS = 'USER_SET_REFERRER_SUCCESS';
|
var USER_SET_REFERRER_SUCCESS = 'USER_SET_REFERRER_SUCCESS';
|
||||||
var USER_SET_REFERRER_FAILURE = 'USER_SET_REFERRER_FAILURE'; // Claims
|
var USER_SET_REFERRER_FAILURE = 'USER_SET_REFERRER_FAILURE';
|
||||||
|
var USER_SET_REFERRER_RESET = 'USER_SET_REFERRER_RESET'; // Claims
|
||||||
|
|
||||||
var FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
var FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
||||||
var FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED';
|
var FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED';
|
||||||
|
@ -4838,6 +4842,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doFetchAccessToken", function() { return doFetchAccessToken; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doFetchAccessToken", function() { return doFetchAccessToken; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserIdentityVerify", function() { return doUserIdentityVerify; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserIdentityVerify", function() { return doUserIdentityVerify; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserInviteNew", function() { return doUserInviteNew; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserInviteNew", function() { return doUserInviteNew; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserSetReferrerReset", function() { return doUserSetReferrerReset; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserSetReferrer", function() { return doUserSetReferrer; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserSetReferrer", function() { return doUserSetReferrer; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doClaimYoutubeChannels", function() { return doClaimYoutubeChannels; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doClaimYoutubeChannels", function() { return doClaimYoutubeChannels; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doCheckYoutubeTransfer", function() { return doCheckYoutubeTransfer; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doCheckYoutubeTransfer", function() { return doCheckYoutubeTransfer; });
|
||||||
|
@ -5256,6 +5261,13 @@ function doUserInviteNew(email) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function doUserSetReferrerReset() {
|
||||||
|
return function (dispatch) {
|
||||||
|
dispatch({
|
||||||
|
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_SET_REFERRER_RESET"]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
function doUserSetReferrer(referrer, shouldClaim) {
|
function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
return (
|
return (
|
||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
|
@ -5263,7 +5275,8 @@ function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
var _ref3 = _asyncToGenerator(
|
var _ref3 = _asyncToGenerator(
|
||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
regeneratorRuntime.mark(function _callee(dispatch, getState) {
|
regeneratorRuntime.mark(function _callee(dispatch, getState) {
|
||||||
var claim, referrerCode, isClaim, uri, response;
|
var claim, referrerCode, _parseURI, isChannel, uri, response;
|
||||||
|
|
||||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (_context.prev = _context.next) {
|
switch (_context.prev = _context.next) {
|
||||||
|
@ -5271,11 +5284,10 @@ function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_SET_REFERRER_STARTED"]
|
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_SET_REFERRER_STARTED"]
|
||||||
});
|
});
|
||||||
referrerCode = referrer;
|
_parseURI = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["parseURI"])(referrer), isChannel = _parseURI.isChannel;
|
||||||
isClaim = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["parseURI"])(referrer).claimId;
|
|
||||||
|
|
||||||
if (!isClaim) {
|
if (!isChannel) {
|
||||||
_context.next = 18;
|
_context.next = 17;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5283,25 +5295,25 @@ function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
claim = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["makeSelectClaimForUri"])(uri)(getState());
|
claim = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["makeSelectClaimForUri"])(uri)(getState());
|
||||||
|
|
||||||
if (claim) {
|
if (claim) {
|
||||||
_context.next = 17;
|
_context.next = 16;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.prev = 7;
|
_context.prev = 6;
|
||||||
_context.next = 10;
|
_context.next = 9;
|
||||||
return lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].resolve({
|
return lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].resolve({
|
||||||
urls: [uri]
|
urls: [uri]
|
||||||
});
|
});
|
||||||
|
|
||||||
case 10:
|
case 9:
|
||||||
response = _context.sent;
|
response = _context.sent;
|
||||||
claim = response && response[uri];
|
claim = response && response[uri];
|
||||||
_context.next = 17;
|
_context.next = 16;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 14:
|
case 13:
|
||||||
_context.prev = 14;
|
_context.prev = 13;
|
||||||
_context.t0 = _context["catch"](7);
|
_context.t0 = _context["catch"](6);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_SET_REFERRER_FAILURE"],
|
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_SET_REFERRER_FAILURE"],
|
||||||
data: {
|
data: {
|
||||||
|
@ -5309,10 +5321,14 @@ function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
case 17:
|
case 16:
|
||||||
referrerCode = claim && claim.permanent_url.replace('lbry://', '');
|
referrerCode = claim && claim.permanent_url && claim.permanent_url.replace('lbry://', '');
|
||||||
|
|
||||||
|
case 17:
|
||||||
|
if (!referrerCode) {
|
||||||
|
referrerCode = referrer;
|
||||||
|
}
|
||||||
|
|
||||||
case 18:
|
|
||||||
_context.prev = 18;
|
_context.prev = 18;
|
||||||
_context.next = 21;
|
_context.next = 21;
|
||||||
return lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].call('user', 'referral', {
|
return lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].call('user', 'referral', {
|
||||||
|
@ -5349,7 +5365,7 @@ function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
return _context.stop();
|
return _context.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, _callee, null, [[7, 14], [18, 25]]);
|
}, _callee, null, [[6, 13], [18, 25]]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return function (_x, _x2) {
|
return function (_x, _x2) {
|
||||||
|
@ -7098,6 +7114,13 @@ reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["USER_SET_REFERRER_
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["USER_SET_REFERRER_RESET"]] = function (state) {
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
referrerSetIsPending: false,
|
||||||
|
referrerSetError: defaultState.referrerSetError
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function userReducer() {
|
function userReducer() {
|
||||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
||||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
|
|
@ -43,6 +43,7 @@ export const USER_YOUTUBE_IMPORT_SUCCESS = 'USER_YOUTUBE_IMPORT_SUCCESS';
|
||||||
export const USER_SET_REFERRER_STARTED = 'USER_SET_REFERRER_STARTED';
|
export const USER_SET_REFERRER_STARTED = 'USER_SET_REFERRER_STARTED';
|
||||||
export const USER_SET_REFERRER_SUCCESS = 'USER_SET_REFERRER_SUCCESS';
|
export const USER_SET_REFERRER_SUCCESS = 'USER_SET_REFERRER_SUCCESS';
|
||||||
export const USER_SET_REFERRER_FAILURE = 'USER_SET_REFERRER_FAILURE';
|
export const USER_SET_REFERRER_FAILURE = 'USER_SET_REFERRER_FAILURE';
|
||||||
|
export const USER_SET_REFERRER_RESET = 'USER_SET_REFERRER_RESET';
|
||||||
|
|
||||||
// Claims
|
// Claims
|
||||||
export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
||||||
|
|
|
@ -65,6 +65,7 @@ export {
|
||||||
doClaimYoutubeChannels,
|
doClaimYoutubeChannels,
|
||||||
doCheckYoutubeTransfer,
|
doCheckYoutubeTransfer,
|
||||||
doUserSetReferrer,
|
doUserSetReferrer,
|
||||||
|
doUserSetReferrerReset,
|
||||||
} from 'redux/actions/user';
|
} from 'redux/actions/user';
|
||||||
export { doFetchCostInfoForUri } from 'redux/actions/cost_info';
|
export { doFetchCostInfoForUri } from 'redux/actions/cost_info';
|
||||||
export { doBlackListedOutpointsSubscribe } from 'redux/actions/blacklist';
|
export { doBlackListedOutpointsSubscribe } from 'redux/actions/blacklist';
|
||||||
|
|
|
@ -398,16 +398,24 @@ export function doUserInviteNew(email) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doUserSetReferrerReset() {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.USER_SET_REFERRER_RESET,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
export function doUserSetReferrer(referrer, shouldClaim) {
|
export function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.USER_SET_REFERRER_STARTED,
|
type: ACTIONS.USER_SET_REFERRER_STARTED,
|
||||||
});
|
});
|
||||||
let claim;
|
let claim;
|
||||||
let referrerCode = referrer;
|
let referrerCode;
|
||||||
|
|
||||||
const isClaim = parseURI(referrer).claimId;
|
const { isChannel } = parseURI(referrer);
|
||||||
if (isClaim) {
|
|
||||||
|
if (isChannel) {
|
||||||
const uri = `lbry://${referrer}`;
|
const uri = `lbry://${referrer}`;
|
||||||
claim = makeSelectClaimForUri(uri)(getState());
|
claim = makeSelectClaimForUri(uri)(getState());
|
||||||
if (!claim) {
|
if (!claim) {
|
||||||
|
@ -421,8 +429,13 @@ export function doUserSetReferrer(referrer, shouldClaim) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
referrerCode = claim && claim.permanent_url.replace('lbry://', '');
|
referrerCode = claim && claim.permanent_url && claim.permanent_url.replace('lbry://', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!referrerCode) {
|
||||||
|
referrerCode = referrer;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Lbryio.call('user', 'referral', { referrer: referrerCode }, 'post');
|
await Lbryio.call('user', 'referral', { referrer: referrerCode }, 'post');
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -290,6 +290,12 @@ reducers[ACTIONS.USER_SET_REFERRER_FAILURE] = (state, action) =>
|
||||||
referrerSetError: action.data.error.message,
|
referrerSetError: action.data.error.message,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
reducers[ACTIONS.USER_SET_REFERRER_RESET] = state =>
|
||||||
|
Object.assign({}, state, {
|
||||||
|
referrerSetIsPending: false,
|
||||||
|
referrerSetError: defaultState.referrerSetError,
|
||||||
|
});
|
||||||
|
|
||||||
export function userReducer(state = defaultState, action) {
|
export function userReducer(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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue