From 4b64c35360afa3a4a80c8c71dad78e314a53f8c0 Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 6 Aug 2021 13:28:58 -0400 Subject: [PATCH 1/7] sunset link --- web/component/nag-sunset.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/component/nag-sunset.jsx b/web/component/nag-sunset.jsx index 37cd8a5ce..27c60eb44 100644 --- a/web/component/nag-sunset.jsx +++ b/web/component/nag-sunset.jsx @@ -4,6 +4,7 @@ import Nag from 'component/common/nag'; import I18nMessage from 'component/i18nMessage'; import * as PAGES from 'constants/pages'; import { useHistory } from 'react-router'; +import Button from '../../ui/component/button'; type Props = { email?: User, @@ -20,7 +21,15 @@ export default function NagSunset(props: Props) { return ( lbry.tv has been retired. You have been magically transported to odysee.com} + message={ + , + }} + > + lbry.tv has been retired (%more%). You have been magically transported to Odysee.com + + } actionText={__('Sign In')} onClick={!email ? handleOnClick : undefined} onClose={onClose} -- 2.45.2 From 1487b83ac5f36dc7a452b5283582f4d38c354490 Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 6 Aug 2021 12:52:06 -0400 Subject: [PATCH 2/7] branded site default --- .env.defaults | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.defaults b/.env.defaults index 1c519e9bb..af17f2375 100644 --- a/.env.defaults +++ b/.env.defaults @@ -41,6 +41,7 @@ SITE_HELP_EMAIL=help@lbry.com LOGO_TITLE=lbry.tv ## Social media TWITTER_ACCOUNT=LBRYcom +BRANDED_SITE=odysee ## IMAGE ASSETS YRBL_HAPPY_IMG_URL=https://cdn.lbryplayer.xyz/api/v3/streams/free/yrbl-happy/7aa50a7e5adaf48691935d55e45d697547392929/839d9a -- 2.45.2 From 5b4d8065e69f207a0aca032a2d6f7ca33a564e8a Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 6 Aug 2021 13:05:30 -0400 Subject: [PATCH 3/7] fix dislike crash when no claim --- ui/redux/selectors/reactions.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/redux/selectors/reactions.js b/ui/redux/selectors/reactions.js index 0058d2095..76feeebdc 100644 --- a/ui/redux/selectors/reactions.js +++ b/ui/redux/selectors/reactions.js @@ -54,11 +54,10 @@ export const makeSelectLikeCountForUri = (uri) => export const makeSelectDislikeCountForUri = (uri) => createSelector(makeSelectClaimForUri(uri), makeSelectReactionsForUri(uri), (claim, reactions) => { - const claimId = claim.claim_id; - - if (!reactions || reactions.my_reactions === null || reactions.others_reactions === null) { + if (!claim || !reactions || reactions.my_reactions === null || reactions.others_reactions === null) { return 0; } + const claimId = claim.claim_id; let count = 0; if (reactions.others_reactions) { -- 2.45.2 From ab2bf481d113cb94f75b3aec520bdb46949ff87e Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 6 Aug 2021 14:14:05 -0400 Subject: [PATCH 4/7] bump --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d387e3456..0c4ee9992 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ "imagesloaded": "^4.1.4", "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#7cc9923ed9ff1940b508842af6be44c8da906a60", + "lbry-redux": "lbryio/lbry-redux#e4d0662100a5f4b28bb1bf3cbc1e51b2eebab5b6", "lbryinc": "lbryio/lbryinc#8f9a58bfc8312a65614fd7327661cdcc502c4e59", "lint-staged": "^7.0.2", "localforage": "^1.7.1", diff --git a/yarn.lock b/yarn.lock index 3206d9f07..9ac3c7109 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10129,9 +10129,9 @@ lazy-val@^1.0.4: yargs "^13.2.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#7cc9923ed9ff1940b508842af6be44c8da906a60: +lbry-redux@lbryio/lbry-redux#e4d0662100a5f4b28bb1bf3cbc1e51b2eebab5b6: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/7cc9923ed9ff1940b508842af6be44c8da906a60" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/e4d0662100a5f4b28bb1bf3cbc1e51b2eebab5b6" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0" -- 2.45.2 From 6b071bab2187fd5d1fd0021bd68a97bc23ed6e33 Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Thu, 5 Aug 2021 17:44:52 -0300 Subject: [PATCH 5/7] Fix amountNeededForTakeover message for bids. --- ui/component/publishBid/index.js | 8 +++++--- ui/component/publishName/index.js | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/component/publishBid/index.js b/ui/component/publishBid/index.js index c570d5d7d..17ce7cf2a 100644 --- a/ui/component/publishBid/index.js +++ b/ui/component/publishBid/index.js @@ -3,23 +3,25 @@ import { makeSelectPublishFormValue, selectMyClaimForUri, selectIsResolvingPublishUris, + selectTakeOverAmount, doUpdatePublishForm, doPrepareEdit, selectBalance, } from 'lbry-redux'; import PublishPage from './view'; -const select = state => ({ +const select = (state) => ({ name: makeSelectPublishFormValue('name')(state), bid: makeSelectPublishFormValue('bid')(state), uri: makeSelectPublishFormValue('uri')(state), isResolvingUri: selectIsResolvingPublishUris(state), balance: selectBalance(state), myClaimForUri: selectMyClaimForUri(state), + amountNeededForTakeover: selectTakeOverAmount(state), }); -const perform = dispatch => ({ - updatePublishForm: value => dispatch(doUpdatePublishForm(value)), +const perform = (dispatch) => ({ + updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)), prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)), }); diff --git a/ui/component/publishName/index.js b/ui/component/publishName/index.js index 67f5142fb..4159056e3 100644 --- a/ui/component/publishName/index.js +++ b/ui/component/publishName/index.js @@ -3,6 +3,7 @@ import { makeSelectPublishFormValue, selectIsStillEditing, selectMyClaimForUri, + selectTakeOverAmount, doUpdatePublishForm, doPrepareEdit, } from 'lbry-redux'; @@ -17,6 +18,7 @@ const select = (state) => ({ myClaimForUri: selectMyClaimForUri(state), activeChannelClaim: selectActiveChannelClaim(state), incognito: selectIncognito(state), + amountNeededForTakeover: selectTakeOverAmount(state), }); const perform = (dispatch) => ({ -- 2.45.2 From 75e748b921385bb5d221ff5ef14848da8955828c Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Fri, 6 Aug 2021 15:33:21 -0300 Subject: [PATCH 6/7] Automatically claim initial rewards (new_user & email_verified) when accessing creating channel, edit channel and upload --- ui/component/channelEdit/index.js | 4 +++ ui/component/channelEdit/view.jsx | 33 ++++++++++++++++------ ui/component/publishForm/index.js | 7 +++-- ui/component/publishForm/view.jsx | 14 +++++++++- ui/redux/actions/rewards.js | 27 +++++++++++------- ui/redux/selectors/rewards.js | 46 +++++++++++++++++-------------- 6 files changed, 89 insertions(+), 42 deletions(-) diff --git a/ui/component/channelEdit/index.js b/ui/component/channelEdit/index.js index 82618960f..8bb161afc 100644 --- a/ui/component/channelEdit/index.js +++ b/ui/component/channelEdit/index.js @@ -17,6 +17,8 @@ import { } from 'lbry-redux'; import { doOpenModal } from 'redux/actions/app'; import { doUpdateBlockListForPublishedChannel } from 'redux/actions/comments'; +import { doClaimInitialRewards } from 'redux/actions/rewards'; +import { selectIsClaimingInitialRewards } from 'redux/selectors/rewards'; import ChannelForm from './view'; const select = (state, props) => ({ @@ -36,6 +38,7 @@ const select = (state, props) => ({ createError: selectCreateChannelError(state), creatingChannel: selectCreatingChannel(state), balance: selectBalance(state), + isClaimingInitialRewards: selectIsClaimingInitialRewards(state), }); const perform = (dispatch) => ({ @@ -50,6 +53,7 @@ const perform = (dispatch) => ({ ); }, clearChannelErrors: () => dispatch(doClearChannelErrors()), + claimInitialRewards: () => dispatch(doClaimInitialRewards()), }); export default connect(select, perform)(ChannelForm); diff --git a/ui/component/channelEdit/view.jsx b/ui/component/channelEdit/view.jsx index ccd452142..f02289a0b 100644 --- a/ui/component/channelEdit/view.jsx +++ b/ui/component/channelEdit/view.jsx @@ -48,6 +48,7 @@ type Props = { createError: string, creatingChannel: boolean, clearChannelErrors: () => void, + claimInitialRewards: () => void, onDone: () => void, openModal: ( id: string, @@ -55,6 +56,7 @@ type Props = { ) => void, uri: string, disabled: boolean, + isClaimingInitialRewards: boolean, }; function ChannelForm(props: Props) { @@ -79,8 +81,10 @@ function ChannelForm(props: Props) { creatingChannel, createError, clearChannelErrors, + claimInitialRewards, openModal, disabled, + isClaimingInitialRewards, } = props; const [nameError, setNameError] = React.useState(undefined); const [bidError, setBidError] = React.useState(''); @@ -94,6 +98,22 @@ function ChannelForm(props: Props) { const languageParam = params.languages; const primaryLanguage = Array.isArray(languageParam) && languageParam.length && languageParam[0]; const secondaryLanguage = Array.isArray(languageParam) && languageParam.length >= 2 && languageParam[1]; + const submitLabel = React.useMemo(() => { + if (isClaimingInitialRewards) { + return __('Claiming credits...'); + } + return creatingChannel || updatingChannel ? __('Submitting') : __('Submit'); + }, [isClaimingInitialRewards, creatingChannel, updatingChannel]); + const submitDisabled = React.useMemo(() => { + return ( + isClaimingInitialRewards || + creatingChannel || + updatingChannel || + nameError || + bidError || + (isNewChannel && !params.name) + ); + }, [isClaimingInitialRewards, creatingChannel, updatingChannel, nameError, bidError, isNewChannel, params]); function getChannelParams() { // fill this in with sdk data @@ -219,6 +239,10 @@ function ChannelForm(props: Props) { clearChannelErrors(); }, [clearChannelErrors]); + React.useEffect(() => { + claimInitialRewards(); + }, [claimInitialRewards]); + // TODO clear and bail after submit return ( <> @@ -453,14 +477,7 @@ function ChannelForm(props: Props) { actions={ <>
-
{errorMsg ? ( diff --git a/ui/component/publishForm/index.js b/ui/component/publishForm/index.js index 47ed81a46..504f2fb5b 100644 --- a/ui/component/publishForm/index.js +++ b/ui/component/publishForm/index.js @@ -18,7 +18,8 @@ import { } from 'lbry-redux'; import * as RENDER_MODES from 'constants/file_render_modes'; import { doPublishDesktop } from 'redux/actions/publish'; -import { selectUnclaimedRewardValue } from 'redux/selectors/rewards'; +import { doClaimInitialRewards } from 'redux/actions/rewards'; +import { selectUnclaimedRewardValue, selectIsClaimingInitialRewards } from 'redux/selectors/rewards'; import { selectModal, selectActiveChannelClaim, @@ -27,8 +28,8 @@ import { } from 'redux/selectors/app'; import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectFileRenderModeForUri } from 'redux/selectors/content'; -import PublishPage from './view'; import { selectUser } from 'redux/selectors/user'; +import PublishPage from './view'; const select = (state) => { const myClaimForUri = selectMyClaimForUri(state); @@ -59,6 +60,7 @@ const select = (state) => { myChannels: selectMyChannelClaims(state), incognito: selectIncognito(state), activeChannelStakedLevel: selectActiveChannelStakedLevel(state), + isClaimingInitialRewards: selectIsClaimingInitialRewards(state), }; }; @@ -70,6 +72,7 @@ const perform = (dispatch) => ({ prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)), resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()), checkAvailability: (name) => dispatch(doCheckPublishNameAvailability(name)), + claimInitialRewards: () => dispatch(doClaimInitialRewards()), }); export default connect(select, perform)(PublishPage); diff --git a/ui/component/publishForm/view.jsx b/ui/component/publishForm/view.jsx index 2089fb6ca..f64aa3ce5 100644 --- a/ui/component/publishForm/view.jsx +++ b/ui/component/publishForm/view.jsx @@ -90,6 +90,8 @@ type Props = { isPostClaim: boolean, permanentUrl: ?string, remoteUrl: ?string, + isClaimingInitialRewards: boolean, + claimInitialRewards: () => void, }; function PublishForm(props: Props) { @@ -128,6 +130,8 @@ function PublishForm(props: Props) { isPostClaim, permanentUrl, remoteUrl, + isClaimingInitialRewards, + claimInitialRewards, } = props; const { replace, location } = useHistory(); @@ -263,6 +267,10 @@ function PublishForm(props: Props) { } }, [activeChannelClaimStr, setSignedMessage]); + useEffect(() => { + claimInitialRewards(); + }, [claimInitialRewards]); + useEffect(() => { if (!modal) { setTimeout(() => { @@ -298,7 +306,10 @@ function PublishForm(props: Props) { const isLivestreamMode = mode === PUBLISH_MODES.LIVESTREAM; let submitLabel; - if (publishing) { + + if (isClaimingInitialRewards) { + submitLabel = __('Claiming credits...'); + } else if (publishing) { if (isStillEditing) { submitLabel = __('Saving...'); } else if (isLivestreamMode) { @@ -623,6 +634,7 @@ function PublishForm(props: Props) { onClick={handlePublish} label={submitLabel} disabled={ + isClaimingInitialRewards || formDisabled || !formValid || uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS || diff --git a/ui/redux/actions/rewards.js b/ui/redux/actions/rewards.js index 4af3b8c07..98351fd42 100644 --- a/ui/redux/actions/rewards.js +++ b/ui/redux/actions/rewards.js @@ -6,13 +6,13 @@ import { doFetchInviteStatus } from 'redux/actions/user'; import rewards from 'rewards'; export function doRewardList() { - return dispatch => { + return (dispatch) => { dispatch({ type: ACTIONS.FETCH_REWARDS_STARTED, }); Lbryio.call('reward', 'list', { multiple_rewards_per_type: true }) - .then(userRewards => { + .then((userRewards) => { dispatch({ type: ACTIONS.FETCH_REWARDS_COMPLETED, data: { userRewards }, @@ -35,7 +35,7 @@ export function doClaimRewardType(rewardType, options = {}) { const reward = rewardType === rewards.TYPE_REWARD_CODE || rewardType === rewards.TYPE_NEW_ANDROID ? { reward_type: rewards.TYPE_REWARD_CODE } - : unclaimedRewards.find(ur => ur.reward_type === rewardType); + : unclaimedRewards.find((ur) => ur.reward_type === rewardType); // Try to claim the email reward right away, even if we haven't called reward_list yet if ( @@ -74,7 +74,7 @@ export function doClaimRewardType(rewardType, options = {}) { data: { reward }, }); - const success = successReward => { + const success = (successReward) => { // Temporary timeout to ensure the sdk has the correct balance after claiming a reward setTimeout(() => { dispatch(doUpdateBalance()).then(() => { @@ -99,7 +99,7 @@ export function doClaimRewardType(rewardType, options = {}) { }, 2000); }; - const failure = error => { + const failure = (error) => { dispatch({ type: ACTIONS.CLAIM_REWARD_FAILURE, data: { @@ -121,6 +121,13 @@ export function doClaimRewardType(rewardType, options = {}) { }; } +export function doClaimInitialRewards() { + return (dispatch) => { + dispatch(doClaimRewardType(rewards.TYPE_NEW_USER)); + dispatch(doClaimRewardType(rewards.TYPE_CONFIRM_EMAIL)); + }; +} + export function doClaimEligiblePurchaseRewards() { return (dispatch, getState) => { const state = getState(); @@ -131,10 +138,10 @@ export function doClaimEligiblePurchaseRewards() { return; } - if (unclaimedRewards.find(ur => ur.reward_type === rewards.TYPE_FIRST_STREAM)) { + if (unclaimedRewards.find((ur) => ur.reward_type === rewards.TYPE_FIRST_STREAM)) { dispatch(doClaimRewardType(rewards.TYPE_FIRST_STREAM)); } else { - [rewards.TYPE_MANY_DOWNLOADS, rewards.TYPE_DAILY_VIEW].forEach(type => { + [rewards.TYPE_MANY_DOWNLOADS, rewards.TYPE_DAILY_VIEW].forEach((type) => { dispatch(doClaimRewardType(type, { failSilently: true })); }); } @@ -142,7 +149,7 @@ export function doClaimEligiblePurchaseRewards() { } export function doClaimRewardClearError(reward) { - return dispatch => { + return (dispatch) => { dispatch({ type: ACTIONS.CLAIM_REWARD_CLEAR_ERROR, data: { reward }, @@ -151,8 +158,8 @@ export function doClaimRewardClearError(reward) { } export function doFetchRewardedContent() { - return dispatch => { - const success = nameToClaimId => { + return (dispatch) => { + const success = (nameToClaimId) => { dispatch({ type: ACTIONS.FETCH_REWARD_CONTENT_COMPLETED, data: { diff --git a/ui/redux/selectors/rewards.js b/ui/redux/selectors/rewards.js index c70b3cdc8..4349021dd 100644 --- a/ui/redux/selectors/rewards.js +++ b/ui/redux/selectors/rewards.js @@ -1,15 +1,15 @@ import { createSelector } from 'reselect'; import REWARDS from 'rewards'; -const selectState = state => state.rewards || {}; +const selectState = (state) => state.rewards || {}; -export const selectUnclaimedRewardsByType = createSelector(selectState, state => state.unclaimedRewardsByType); +export const selectUnclaimedRewardsByType = createSelector(selectState, (state) => state.unclaimedRewardsByType); -export const selectClaimedRewardsById = createSelector(selectState, state => state.claimedRewardsById); +export const selectClaimedRewardsById = createSelector(selectState, (state) => state.claimedRewardsById); -export const selectClaimedRewards = createSelector(selectClaimedRewardsById, byId => Object.values(byId) || []); +export const selectClaimedRewards = createSelector(selectClaimedRewardsById, (byId) => Object.values(byId) || []); -export const selectClaimedRewardsByTransactionId = createSelector(selectClaimedRewards, rewards => +export const selectClaimedRewardsByTransactionId = createSelector(selectClaimedRewards, (rewards) => rewards.reduce((mapParam, reward) => { const map = mapParam; map[reward.transaction_id] = reward; @@ -17,47 +17,51 @@ export const selectClaimedRewardsByTransactionId = createSelector(selectClaimedR }, {}) ); -export const selectUnclaimedRewards = createSelector(selectState, state => state.unclaimedRewards); +export const selectUnclaimedRewards = createSelector(selectState, (state) => state.unclaimedRewards); -export const selectFetchingRewards = createSelector(selectState, state => !!state.fetching); +export const selectFetchingRewards = createSelector(selectState, (state) => !!state.fetching); -export const selectUnclaimedRewardValue = createSelector(selectUnclaimedRewards, rewards => +export const selectUnclaimedRewardValue = createSelector(selectUnclaimedRewards, (rewards) => rewards.reduce((sum, reward) => sum + reward.reward_amount, 0) ); -export const selectClaimsPendingByType = createSelector(selectState, state => state.claimPendingByType); +export const selectClaimsPendingByType = createSelector(selectState, (state) => state.claimPendingByType); const selectIsClaimRewardPending = (state, props) => selectClaimsPendingByType(state, props)[props.reward_type]; export const makeSelectIsRewardClaimPending = () => - createSelector(selectIsClaimRewardPending, isClaiming => isClaiming); + createSelector(selectIsClaimRewardPending, (isClaiming) => isClaiming); -export const selectClaimErrorsByType = createSelector(selectState, state => state.claimErrorsByType); +export const selectClaimErrorsByType = createSelector(selectState, (state) => state.claimErrorsByType); const selectClaimRewardError = (state, props) => selectClaimErrorsByType(state, props)[props.reward_type]; -export const makeSelectClaimRewardError = () => createSelector(selectClaimRewardError, errorMessage => errorMessage); +export const makeSelectClaimRewardError = () => createSelector(selectClaimRewardError, (errorMessage) => errorMessage); const selectRewardByType = (state, rewardType) => - selectUnclaimedRewards(state).find(reward => reward.reward_type === rewardType); + selectUnclaimedRewards(state).find((reward) => reward.reward_type === rewardType); -export const makeSelectRewardByType = () => createSelector(selectRewardByType, reward => reward); +export const makeSelectRewardByType = () => createSelector(selectRewardByType, (reward) => reward); const selectRewardByClaimCode = (state, claimCode) => - selectUnclaimedRewards(state).find(reward => reward.claim_code === claimCode); + selectUnclaimedRewards(state).find((reward) => reward.claim_code === claimCode); -export const makeSelectRewardByClaimCode = () => createSelector(selectRewardByClaimCode, reward => reward); +export const makeSelectRewardByClaimCode = () => createSelector(selectRewardByClaimCode, (reward) => reward); export const makeSelectRewardAmountByType = () => - createSelector(selectRewardByType, reward => (reward ? reward.reward_amount : 0)); + createSelector(selectRewardByType, (reward) => (reward ? reward.reward_amount : 0)); -export const selectRewardContentClaimIds = createSelector(selectState, state => state.rewardedContentClaimIds); +export const selectRewardContentClaimIds = createSelector(selectState, (state) => state.rewardedContentClaimIds); export const selectReferralReward = createSelector( selectUnclaimedRewards, - unclaimedRewards => unclaimedRewards.filter(reward => reward.reward_type === REWARDS.TYPE_REFERRAL)[0] + (unclaimedRewards) => unclaimedRewards.filter((reward) => reward.reward_type === REWARDS.TYPE_REFERRAL)[0] ); -export const selectHasUnclaimedRefereeReward = createSelector(selectUnclaimedRewards, unclaimedRewards => - unclaimedRewards.some(reward => reward.reward_type === REWARDS.TYPE_REFEREE) +export const selectHasUnclaimedRefereeReward = createSelector(selectUnclaimedRewards, (unclaimedRewards) => + unclaimedRewards.some((reward) => reward.reward_type === REWARDS.TYPE_REFEREE) ); + +export const selectIsClaimingInitialRewards = createSelector(selectClaimsPendingByType, (claimsPendingByType) => { + return claimsPendingByType[REWARDS.TYPE_NEW_USER] || claimsPendingByType[REWARDS.TYPE_CONFIRM_EMAIL]; +}); -- 2.45.2 From de7c6788b43b75345976410cc367fe0443c7cb4c Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Mon, 16 Aug 2021 21:54:08 -0300 Subject: [PATCH 7/7] Do not try to get initial rewards if already claimed. --- ui/component/channelEdit/index.js | 3 ++- ui/component/channelEdit/view.jsx | 8 ++++++-- ui/component/publishForm/index.js | 7 ++++++- ui/component/publishForm/view.jsx | 8 ++++++-- ui/redux/selectors/rewards.js | 9 ++++++++- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ui/component/channelEdit/index.js b/ui/component/channelEdit/index.js index 8bb161afc..9a195039b 100644 --- a/ui/component/channelEdit/index.js +++ b/ui/component/channelEdit/index.js @@ -18,7 +18,7 @@ import { import { doOpenModal } from 'redux/actions/app'; import { doUpdateBlockListForPublishedChannel } from 'redux/actions/comments'; import { doClaimInitialRewards } from 'redux/actions/rewards'; -import { selectIsClaimingInitialRewards } from 'redux/selectors/rewards'; +import { selectIsClaimingInitialRewards, selectHasClaimedInitialRewards } from 'redux/selectors/rewards'; import ChannelForm from './view'; const select = (state, props) => ({ @@ -39,6 +39,7 @@ const select = (state, props) => ({ creatingChannel: selectCreatingChannel(state), balance: selectBalance(state), isClaimingInitialRewards: selectIsClaimingInitialRewards(state), + hasClaimedInitialRewards: selectHasClaimedInitialRewards(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/channelEdit/view.jsx b/ui/component/channelEdit/view.jsx index f02289a0b..61c9df69f 100644 --- a/ui/component/channelEdit/view.jsx +++ b/ui/component/channelEdit/view.jsx @@ -57,6 +57,7 @@ type Props = { uri: string, disabled: boolean, isClaimingInitialRewards: boolean, + hasClaimedInitialRewards: boolean, }; function ChannelForm(props: Props) { @@ -85,6 +86,7 @@ function ChannelForm(props: Props) { openModal, disabled, isClaimingInitialRewards, + hasClaimedInitialRewards, } = props; const [nameError, setNameError] = React.useState(undefined); const [bidError, setBidError] = React.useState(''); @@ -240,8 +242,10 @@ function ChannelForm(props: Props) { }, [clearChannelErrors]); React.useEffect(() => { - claimInitialRewards(); - }, [claimInitialRewards]); + if (!hasClaimedInitialRewards) { + claimInitialRewards(); + } + }, [hasClaimedInitialRewards, claimInitialRewards]); // TODO clear and bail after submit return ( diff --git a/ui/component/publishForm/index.js b/ui/component/publishForm/index.js index 504f2fb5b..58b24bdb5 100644 --- a/ui/component/publishForm/index.js +++ b/ui/component/publishForm/index.js @@ -19,7 +19,11 @@ import { import * as RENDER_MODES from 'constants/file_render_modes'; import { doPublishDesktop } from 'redux/actions/publish'; import { doClaimInitialRewards } from 'redux/actions/rewards'; -import { selectUnclaimedRewardValue, selectIsClaimingInitialRewards } from 'redux/selectors/rewards'; +import { + selectUnclaimedRewardValue, + selectIsClaimingInitialRewards, + selectHasClaimedInitialRewards, +} from 'redux/selectors/rewards'; import { selectModal, selectActiveChannelClaim, @@ -61,6 +65,7 @@ const select = (state) => { incognito: selectIncognito(state), activeChannelStakedLevel: selectActiveChannelStakedLevel(state), isClaimingInitialRewards: selectIsClaimingInitialRewards(state), + hasClaimedInitialRewards: selectHasClaimedInitialRewards(state), }; }; diff --git a/ui/component/publishForm/view.jsx b/ui/component/publishForm/view.jsx index f64aa3ce5..eac23885b 100644 --- a/ui/component/publishForm/view.jsx +++ b/ui/component/publishForm/view.jsx @@ -92,6 +92,7 @@ type Props = { remoteUrl: ?string, isClaimingInitialRewards: boolean, claimInitialRewards: () => void, + hasClaimedInitialRewards: boolean, }; function PublishForm(props: Props) { @@ -132,6 +133,7 @@ function PublishForm(props: Props) { remoteUrl, isClaimingInitialRewards, claimInitialRewards, + hasClaimedInitialRewards, } = props; const { replace, location } = useHistory(); @@ -268,8 +270,10 @@ function PublishForm(props: Props) { }, [activeChannelClaimStr, setSignedMessage]); useEffect(() => { - claimInitialRewards(); - }, [claimInitialRewards]); + if (!hasClaimedInitialRewards) { + claimInitialRewards(); + } + }, [hasClaimedInitialRewards, claimInitialRewards]); useEffect(() => { if (!modal) { diff --git a/ui/redux/selectors/rewards.js b/ui/redux/selectors/rewards.js index 4349021dd..00d6d390a 100644 --- a/ui/redux/selectors/rewards.js +++ b/ui/redux/selectors/rewards.js @@ -63,5 +63,12 @@ export const selectHasUnclaimedRefereeReward = createSelector(selectUnclaimedRew ); export const selectIsClaimingInitialRewards = createSelector(selectClaimsPendingByType, (claimsPendingByType) => { - return claimsPendingByType[REWARDS.TYPE_NEW_USER] || claimsPendingByType[REWARDS.TYPE_CONFIRM_EMAIL]; + return !!(claimsPendingByType[REWARDS.TYPE_NEW_USER] || claimsPendingByType[REWARDS.TYPE_CONFIRM_EMAIL]); +}); + +export const selectHasClaimedInitialRewards = createSelector(selectClaimedRewardsById, (claimedRewardsById) => { + const claims = Object.values(claimedRewardsById); + const newUserClaimed = !!claims.find((claim) => claim && claim.reward_type === REWARDS.TYPE_NEW_USER); + const confirmEmailClaimed = !!claims.find((claim) => claim && claim.reward_type === REWARDS.TYPE_CONFIRM_EMAIL); + return newUserClaimed && confirmEmailClaimed; }); -- 2.45.2