From 94cc7a2d9d24d2da4b76e0278b35f7314a99c1ad Mon Sep 17 00:00:00 2001 From: jessop Date: Tue, 14 Jan 2020 09:57:34 -0500 Subject: [PATCH] review changes --- ui/component/commentCreate/view.jsx | 2 +- ui/component/header/view.jsx | 6 +- ui/component/inviteNew/view.jsx | 121 +++++++++++++++++----------- ui/component/invited/view.jsx | 91 ++++++++++++--------- ui/component/publishForm/view.jsx | 7 +- ui/component/selectChannel/view.jsx | 49 +++++++++-- ui/modal/modalSetReferrer/view.jsx | 3 +- 7 files changed, 176 insertions(+), 103 deletions(-) diff --git a/ui/component/commentCreate/view.jsx b/ui/component/commentCreate/view.jsx index 7ae9da461..5f7f6e89a 100644 --- a/ui/component/commentCreate/view.jsx +++ b/ui/component/commentCreate/view.jsx @@ -59,7 +59,7 @@ export function CommentCreate(props: Props) { return (
- + { {/* Commented out until new invite system is implemented */} - {/* history.push(`/$/${PAGES.INVITE}`)}> + history.push(`/$/${PAGES.INVITE}`)}> - {__('Invite A Friend')} - */} + {__('Invites')} + {authenticated ? ( diff --git a/ui/component/inviteNew/view.jsx b/ui/component/inviteNew/view.jsx index fc4e50c9d..697f1be38 100644 --- a/ui/component/inviteNew/view.jsx +++ b/ui/component/inviteNew/view.jsx @@ -15,7 +15,7 @@ type Props = { isPending: boolean, referralLink: string, referralCode: string, - channels: any, + channels: ?Array, resolvingUris: Array, resolveUris: (Array) => void, }; @@ -41,8 +41,9 @@ function InviteNew(props: Props) { function handleReferralChange(code) { setReferralSource(code); // TODO: keep track of this in an array? - if (code !== referralCode) { - analytics.apiLogPublish(channels.find(ch => ch.name === code)); + const matchingChannel = channels && channels.find(ch => ch.name === code); + if (matchingChannel) { + analytics.apiLogPublish(matchingChannel); } } @@ -55,9 +56,11 @@ function InviteNew(props: Props) { const topChannel = channels && - channels.reduce((top, channel) => - (top && top.meta && top.meta.claims_in_channel) > channel.meta.claims_in_channel ? top : channel - ); + channels.reduce((top, channel) => { + const topClaimCount = (top && top.meta && top.meta.claims_in_channel) || 0; + const currentClaimCount = (channel && channel.meta && channel.meta.claims_in_channel) || 0; + return topClaimCount >= currentClaimCount ? top : channel; + }); const referralString = channels && channels.length && referralSource !== referralCode ? lookupUrlByClaimName(referralSource, channels) @@ -67,7 +70,7 @@ function InviteNew(props: Props) { useEffect(() => { // resolve once, after we have channel list - if (!hasResolved && !resolveStarted && channelCount) { + if (!hasResolved && !resolveStarted && channelCount && uris) { setResolveStarted(true); resolveUris(uris.split(',')); } @@ -93,47 +96,71 @@ function InviteNew(props: Props) { } return ( - - - handleReferralChange(channel)} - label={'Code or Channel'} - injected={[referralCode]} - /> - - - } - onChange={event => { - handleEmailChanged(event); - }} - /> -

- , - referral_faq_link: