add action/reducer/selector for fetching rewarded content #5
5 changed files with 102 additions and 7 deletions
67
dist/bundle.js
vendored
67
dist/bundle.js
vendored
|
@ -104,7 +104,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.selectUserInviteNewErrorMessage = exports.selectUserInviteNewIsPending = exports.selectUserInviteStatusFailed = exports.selectUserInvitees = exports.selectUserInvitesRemaining = exports.selectUserInviteStatusIsPending = exports.selectAccessToken = exports.selectUserIsVerificationCandidate = exports.selectIdentityVerifyErrorMessage = exports.selectIdentityVerifyIsPending = exports.selectPhoneVerifyIsPending = exports.selectPhoneVerifyErrorMessage = exports.selectEmailVerifyErrorMessage = exports.selectEmailVerifyIsPending = exports.selectPhoneNewIsPending = exports.selectPhoneNewErrorMessage = exports.selectEmailNewErrorMessage = exports.selectEmailNewIsPending = exports.selectUserIsRewardApproved = exports.selectPhoneToVerify = exports.selectEmailToVerify = exports.selectUserCountryCode = exports.selectUserPhone = exports.selectUserEmail = exports.selectUser = exports.selectUserIsPending = exports.selectAuthenticationIsPending = exports.selectRewardByType = exports.selectClaimRewardError = exports.selectClaimErrorsByType = exports.selectIsClaimRewardPending = exports.selectClaimsPendingByType = exports.selectUnclaimedRewardValue = exports.selectFetchingRewards = exports.selectUnclaimedRewards = exports.selectClaimedRewardsByTransactionId = exports.selectClaimedRewards = exports.selectClaimedRewardsById = exports.selectUnclaimedRewardsByType = exports.makeSelectRewardByType = exports.makeSelectRewardAmountByType = exports.makeSelectIsRewardClaimPending = exports.makeSelectClaimRewardError = exports.selectIsAuthenticating = exports.selectAuthToken = exports.userReducer = exports.rewardsReducer = exports.authReducer = exports.doFetchAccessToken = exports.doUserPhoneVerify = exports.doUserPhoneVerifyFailure = exports.doUserPhoneReset = exports.doUserPhoneNew = exports.doUserEmailVerify = exports.doUserEmailVerifyFailure = exports.doUserEmailToVerify = exports.doUserEmailNew = exports.doUserFetch = exports.doAuthenticate = exports.doInstallNew = exports.doFetchInviteStatus = exports.doClaimRewardClearError = exports.doClaimEligiblePurchaseRewards = exports.doClaimRewardType = exports.doRewardList = exports.doGenerateAuthToken = exports.rewards = exports.Lbryio = exports.LBRYINC_ACTIONS = undefined;
|
||||
exports.selectUserInviteNewErrorMessage = exports.selectUserInviteNewIsPending = exports.selectUserInviteStatusFailed = exports.selectUserInvitees = exports.selectUserInvitesRemaining = exports.selectUserInviteStatusIsPending = exports.selectAccessToken = exports.selectUserIsVerificationCandidate = exports.selectIdentityVerifyErrorMessage = exports.selectIdentityVerifyIsPending = exports.selectPhoneVerifyIsPending = exports.selectPhoneVerifyErrorMessage = exports.selectEmailVerifyErrorMessage = exports.selectEmailVerifyIsPending = exports.selectPhoneNewIsPending = exports.selectPhoneNewErrorMessage = exports.selectEmailNewErrorMessage = exports.selectEmailNewIsPending = exports.selectUserIsRewardApproved = exports.selectPhoneToVerify = exports.selectEmailToVerify = exports.selectUserCountryCode = exports.selectUserPhone = exports.selectUserEmail = exports.selectUser = exports.selectUserIsPending = exports.selectAuthenticationIsPending = exports.selectRewardContentClaimIds = exports.selectRewardByType = exports.selectClaimRewardError = exports.selectClaimErrorsByType = exports.selectIsClaimRewardPending = exports.selectClaimsPendingByType = exports.selectUnclaimedRewardValue = exports.selectFetchingRewards = exports.selectUnclaimedRewards = exports.selectClaimedRewardsByTransactionId = exports.selectClaimedRewards = exports.selectClaimedRewardsById = exports.selectUnclaimedRewardsByType = exports.makeSelectRewardByType = exports.makeSelectRewardAmountByType = exports.makeSelectIsRewardClaimPending = exports.makeSelectClaimRewardError = exports.selectIsAuthenticating = exports.selectAuthToken = exports.userReducer = exports.rewardsReducer = exports.authReducer = exports.doFetchAccessToken = exports.doUserPhoneVerify = exports.doUserPhoneVerifyFailure = exports.doUserPhoneReset = exports.doUserPhoneNew = exports.doUserEmailVerify = exports.doUserEmailVerifyFailure = exports.doUserEmailToVerify = exports.doUserEmailNew = exports.doUserFetch = exports.doAuthenticate = exports.doInstallNew = exports.doFetchInviteStatus = exports.doFetchRewardedContent = exports.doClaimRewardClearError = exports.doClaimEligiblePurchaseRewards = exports.doClaimRewardType = exports.doRewardList = exports.doGenerateAuthToken = exports.rewards = exports.Lbryio = exports.LBRYINC_ACTIONS = undefined;
|
||||
|
||||
var _auth = __webpack_require__(1);
|
||||
|
||||
|
@ -141,6 +141,12 @@ Object.defineProperty(exports, 'doClaimRewardClearError', {
|
|||
return _rewards.doClaimRewardClearError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'doFetchRewardedContent', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _rewards.doFetchRewardedContent;
|
||||
}
|
||||
});
|
||||
|
||||
var _user = __webpack_require__(14);
|
||||
|
||||
|
@ -363,6 +369,12 @@ Object.defineProperty(exports, 'selectRewardByType', {
|
|||
return _rewards3.selectRewardByType;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'selectRewardContentClaimIds', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _rewards3.selectRewardContentClaimIds;
|
||||
}
|
||||
});
|
||||
|
||||
var _user3 = __webpack_require__(12);
|
||||
|
||||
|
@ -7783,6 +7795,7 @@ exports.doRewardList = doRewardList;
|
|||
exports.doClaimRewardType = doClaimRewardType;
|
||||
exports.doClaimEligiblePurchaseRewards = doClaimEligiblePurchaseRewards;
|
||||
exports.doClaimRewardClearError = doClaimRewardClearError;
|
||||
exports.doFetchRewardedContent = doFetchRewardedContent;
|
||||
|
||||
var _lbryio = __webpack_require__(3);
|
||||
|
||||
|
@ -7911,6 +7924,32 @@ function doClaimRewardClearError(reward) {
|
|||
};
|
||||
}
|
||||
|
||||
function doFetchRewardedContent() {
|
||||
return function (dispatch) {
|
||||
var success = function success(nameToClaimId) {
|
||||
dispatch({
|
||||
type: _lbryRedux.ACTIONS.FETCH_REWARD_CONTENT_COMPLETED,
|
||||
data: {
|
||||
claimIds: Object.values(nameToClaimId),
|
||||
success: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var failure = function failure() {
|
||||
dispatch({
|
||||
type: _lbryRedux.ACTIONS.FETCH_REWARD_CONTENT_COMPLETED,
|
||||
data: {
|
||||
claimIds: [],
|
||||
success: false
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
_lbryio2.default.call('reward', 'list_featured').then(success, failure);
|
||||
};
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
/* 10 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
@ -7921,7 +7960,7 @@ function doClaimRewardClearError(reward) {
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.makeSelectRewardAmountByType = exports.makeSelectRewardByType = exports.makeSelectClaimRewardError = exports.selectClaimErrorsByType = exports.makeSelectIsRewardClaimPending = exports.selectClaimsPendingByType = exports.selectUnclaimedRewardValue = exports.selectFetchingRewards = exports.selectUnclaimedRewards = exports.selectClaimedRewardsByTransactionId = exports.selectClaimedRewards = exports.selectClaimedRewardsById = exports.selectUnclaimedRewardsByType = undefined;
|
||||
exports.selectRewardContentClaimIds = exports.makeSelectRewardAmountByType = exports.makeSelectRewardByType = exports.makeSelectClaimRewardError = exports.selectClaimErrorsByType = exports.makeSelectIsRewardClaimPending = exports.selectClaimsPendingByType = exports.selectUnclaimedRewardValue = exports.selectFetchingRewards = exports.selectUnclaimedRewards = exports.selectClaimedRewardsByTransactionId = exports.selectClaimedRewards = exports.selectClaimedRewardsById = exports.selectUnclaimedRewardsByType = undefined;
|
||||
|
||||
var _reselect = __webpack_require__(11);
|
||||
|
||||
|
@ -8009,6 +8048,10 @@ var makeSelectRewardAmountByType = exports.makeSelectRewardAmountByType = functi
|
|||
});
|
||||
};
|
||||
|
||||
var selectRewardContentClaimIds = exports.selectRewardContentClaimIds = (0, _reselect.createSelector)(selectState, function (state) {
|
||||
return state.rewardedContentClaimIds;
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
/* 11 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
@ -8434,7 +8477,7 @@ function doFetchInviteStatus() {
|
|||
}
|
||||
|
||||
function doInstallNew(appVersion) {
|
||||
var os_system = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
var os = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
|
||||
var payload = { app_version: appVersion };
|
||||
_lbryRedux.Lbry.status().then(function (status) {
|
||||
|
@ -8442,7 +8485,7 @@ function doInstallNew(appVersion) {
|
|||
payload.node_id = status.lbry_id;
|
||||
_lbryRedux.Lbry.version().then(function (version) {
|
||||
payload.daemon_version = version.lbrynet_version;
|
||||
payload.operating_system = os_system || version.os_system;
|
||||
payload.operating_system = os || version.os_system;
|
||||
payload.platform = version.platform;
|
||||
_lbryio2.default.call('install', 'new', payload);
|
||||
});
|
||||
|
@ -8451,7 +8494,7 @@ function doInstallNew(appVersion) {
|
|||
|
||||
// TODO: Call doInstallNew separately so we don't have to pass appVersion and os_system params?
|
||||
function doAuthenticate(appVersion) {
|
||||
var os_system = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
var os = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
|
||||
return function (dispatch) {
|
||||
dispatch({
|
||||
|
@ -8465,7 +8508,7 @@ function doAuthenticate(appVersion) {
|
|||
});
|
||||
dispatch((0, _rewards.doRewardList)());
|
||||
dispatch(doFetchInviteStatus());
|
||||
doInstallNew(appVersion, os_system);
|
||||
doInstallNew(appVersion, os);
|
||||
}).catch(function (error) {
|
||||
dispatch((0, _lbryRedux.doNotify)({ id: _lbryRedux.MODALS.AUTHENTICATION_FAILURE }));
|
||||
dispatch({
|
||||
|
@ -8731,7 +8774,8 @@ var defaultState = {
|
|||
claimedRewardsById: {}, // id => reward
|
||||
unclaimedRewards: [],
|
||||
claimPendingByType: {},
|
||||
claimErrorsByType: {}
|
||||
claimErrorsByType: {},
|
||||
rewardedContentClaimIds: []
|
||||
};
|
||||
|
||||
reducers[_lbryRedux.ACTIONS.FETCH_REWARDS_STARTED] = function (state) {
|
||||
|
@ -8828,6 +8872,15 @@ reducers[_lbryRedux.ACTIONS.CLAIM_REWARD_CLEAR_ERROR] = function (state, action)
|
|||
return setClaimRewardState(state, reward, state.claimPendingByType[reward.reward_type], '');
|
||||
};
|
||||
|
||||
reducers[_lbryRedux.ACTIONS.FETCH_REWARD_CONTENT_COMPLETED] = function (state, action) {
|
||||
var claimIds = action.data.claimIds;
|
||||
|
||||
|
||||
return Object.assign({}, state, {
|
||||
rewardedContentClaimIds: claimIds
|
||||
});
|
||||
};
|
||||
|
||||
function rewardsReducer() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
||||
var action = arguments[1];
|
||||
|
|
|
@ -15,6 +15,7 @@ export {
|
|||
doClaimRewardType,
|
||||
doClaimEligiblePurchaseRewards,
|
||||
doClaimRewardClearError,
|
||||
doFetchRewardedContent,
|
||||
} from 'redux/actions/rewards';
|
||||
export {
|
||||
doFetchInviteStatus,
|
||||
|
@ -56,6 +57,7 @@ export {
|
|||
selectClaimErrorsByType,
|
||||
selectClaimRewardError,
|
||||
selectRewardByType,
|
||||
selectRewardContentClaimIds,
|
||||
} from 'redux/selectors/rewards';
|
||||
export {
|
||||
selectAuthenticationIsPending,
|
||||
|
|
|
@ -112,3 +112,29 @@ export function doClaimRewardClearError(reward) {
|
|||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doFetchRewardedContent() {
|
||||
return dispatch => {
|
||||
const success = nameToClaimId => {
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_REWARD_CONTENT_COMPLETED,
|
||||
data: {
|
||||
claimIds: Object.values(nameToClaimId),
|
||||
success: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const failure = () => {
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_REWARD_CONTENT_COMPLETED,
|
||||
data: {
|
||||
claimIds: [],
|
||||
success: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Lbryio.call('reward', 'list_featured').then(success, failure);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ const defaultState = {
|
|||
unclaimedRewards: [],
|
||||
claimPendingByType: {},
|
||||
claimErrorsByType: {},
|
||||
rewardedContentClaimIds: [],
|
||||
};
|
||||
|
||||
reducers[ACTIONS.FETCH_REWARDS_STARTED] = state =>
|
||||
|
@ -91,6 +92,14 @@ reducers[ACTIONS.CLAIM_REWARD_CLEAR_ERROR] = (state, action) => {
|
|||
return setClaimRewardState(state, reward, state.claimPendingByType[reward.reward_type], '');
|
||||
};
|
||||
|
||||
reducers[ACTIONS.FETCH_REWARD_CONTENT_COMPLETED] = (state, action) => {
|
||||
const { claimIds } = action.data;
|
||||
|
||||
return Object.assign({}, state, {
|
||||
rewardedContentClaimIds: claimIds,
|
||||
});
|
||||
};
|
||||
|
||||
export function rewardsReducer(state = defaultState, action) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
|
|
|
@ -62,3 +62,8 @@ export const makeSelectRewardByType = () => createSelector(selectRewardByType, r
|
|||
|
||||
export const makeSelectRewardAmountByType = () =>
|
||||
createSelector(selectRewardByType, reward => (reward ? reward.reward_amount : 0));
|
||||
|
||||
export const selectRewardContentClaimIds = createSelector(
|
||||
selectState,
|
||||
state => state.rewardedContentClaimIds
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue