mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
channel page and invite page take advantage of resolved channel list
This commit is contained in:
parent
0a0a8c4658
commit
cda643be26
4 changed files with 14 additions and 42 deletions
|
@ -130,7 +130,7 @@
|
||||||
"imagesloaded": "^4.1.4",
|
"imagesloaded": "^4.1.4",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||||
"lbry-redux": "lbryio/lbry-redux#adebb2d6259e9f69ca055a8a8c0c01fac0af6124",
|
"lbry-redux": "lbryio/lbry-redux#50aa80d139c7863503b8dfc77947e3cdf3ee801d",
|
||||||
"lbryinc": "lbryio/lbryinc#6a59102c52673502569d2c43bd4ee58c315fb2e4",
|
"lbryinc": "lbryio/lbryinc#6a59102c52673502569d2c43bd4ee58c315fb2e4",
|
||||||
"lint-staged": "^7.0.2",
|
"lint-staged": "^7.0.2",
|
||||||
"localforage": "^1.7.1",
|
"localforage": "^1.7.1",
|
||||||
|
|
|
@ -929,7 +929,6 @@
|
||||||
"Custom": "Custom",
|
"Custom": "Custom",
|
||||||
"Playing in %seconds_left% seconds": "Playing in %seconds_left% seconds",
|
"Playing in %seconds_left% seconds": "Playing in %seconds_left% seconds",
|
||||||
"Up Next by %channel%": "Up Next by %channel%",
|
"Up Next by %channel%": "Up Next by %channel%",
|
||||||
"Install Now": "Install Now",
|
|
||||||
"Repost": "Repost",
|
"Repost": "Repost",
|
||||||
"Repost your favorite claims to help more people discover them!": "Repost your favorite claims to help more people discover them!",
|
"Repost your favorite claims to help more people discover them!": "Repost your favorite claims to help more people discover them!",
|
||||||
"Advanced": "Advanced",
|
"Advanced": "Advanced",
|
||||||
|
@ -941,5 +940,13 @@
|
||||||
"Effective Amount": "Effective Amount",
|
"Effective Amount": "Effective Amount",
|
||||||
"Is Controlling": "Is Controlling",
|
"Is Controlling": "Is Controlling",
|
||||||
"Claim ID": "Claim ID",
|
"Claim ID": "Claim ID",
|
||||||
"Official YouTube Creator - Last updated %time_ago%": "Official YouTube Creator - Last updated %time_ago%"
|
"Official YouTube Creator - Last updated %time_ago%": "Official YouTube Creator - Last updated %time_ago%",
|
||||||
|
"Install Now": "Install Now",
|
||||||
|
"Invite Link": "Invite Link",
|
||||||
|
"Share this link with friends (or enemies) and get %reward_amount% LBC when they join lbry.tv": "Share this link with friends (or enemies) and get %reward_amount% LBC when they join lbry.tv",
|
||||||
|
"Your invite link": "Your invite link",
|
||||||
|
"rewards": "rewards",
|
||||||
|
"Invite by Email": "Invite by Email",
|
||||||
|
"Invite someone you know by email and earn %reward_amount% LBC when they join lbry.tv.": "Invite someone you know by email and earn %reward_amount% LBC when they join lbry.tv.",
|
||||||
|
"Earn %rewards_link% for inviting your friends. Read our %referral_faq_link% to learn more.": "Earn %rewards_link% for inviting your friends. Read our %referral_faq_link% to learn more."
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,7 @@ import {
|
||||||
selectUserInviteReferralCode,
|
selectUserInviteReferralCode,
|
||||||
doUserInviteNew,
|
doUserInviteNew,
|
||||||
} from 'lbryinc';
|
} from 'lbryinc';
|
||||||
import {
|
import { selectMyChannelClaims, selectFetchingMyChannels, doFetchChannelListMine } from 'lbry-redux';
|
||||||
selectMyChannelClaims,
|
|
||||||
selectFetchingMyChannels,
|
|
||||||
doFetchChannelListMine,
|
|
||||||
doResolveUris,
|
|
||||||
selectResolvingUris,
|
|
||||||
} from 'lbry-redux';
|
|
||||||
import InviteNew from './view';
|
import InviteNew from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
@ -24,13 +18,11 @@ const select = state => ({
|
||||||
isPending: selectUserInviteNewIsPending(state),
|
isPending: selectUserInviteNewIsPending(state),
|
||||||
channels: selectMyChannelClaims(state),
|
channels: selectMyChannelClaims(state),
|
||||||
fetchingChannels: selectFetchingMyChannels(state),
|
fetchingChannels: selectFetchingMyChannels(state),
|
||||||
resolvingUris: selectResolvingUris(state),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
inviteNew: email => dispatch(doUserInviteNew(email)),
|
inviteNew: email => dispatch(doUserInviteNew(email)),
|
||||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||||
resolveUris: uris => dispatch(doResolveUris(uris)),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
@ -16,12 +16,10 @@ type Props = {
|
||||||
referralLink: string,
|
referralLink: string,
|
||||||
referralCode: string,
|
referralCode: string,
|
||||||
channels: ?Array<ChannelClaim>,
|
channels: ?Array<ChannelClaim>,
|
||||||
resolvingUris: Array<string>,
|
|
||||||
resolveUris: (Array<string>) => void,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function InviteNew(props: Props) {
|
function InviteNew(props: Props) {
|
||||||
const { inviteNew, errorMessage, isPending, referralCode = '', channels, resolveUris, resolvingUris } = props;
|
const { inviteNew, errorMessage, isPending, referralCode = '', channels } = props;
|
||||||
const rewardAmount = 20;
|
const rewardAmount = 20;
|
||||||
|
|
||||||
// Email
|
// Email
|
||||||
|
@ -36,9 +34,6 @@ function InviteNew(props: Props) {
|
||||||
|
|
||||||
// Referral link
|
// Referral link
|
||||||
const [referralSource, setReferralSource] = useState(referralCode);
|
const [referralSource, setReferralSource] = useState(referralCode);
|
||||||
/* Canonical Referral links
|
|
||||||
* We need to make sure our channels are resolved so that canonical_url is present
|
|
||||||
*/
|
|
||||||
|
|
||||||
function handleReferralChange(code) {
|
function handleReferralChange(code) {
|
||||||
setReferralSource(code);
|
setReferralSource(code);
|
||||||
|
@ -49,13 +44,6 @@ function InviteNew(props: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [resolveStarted, setResolveStarted] = useState(false);
|
|
||||||
const [hasResolved, setHasResolved] = useState(false);
|
|
||||||
// join them so that useEffect doesn't update on new objects
|
|
||||||
const uris = channels && channels.map(channel => channel.permanent_url).join(',');
|
|
||||||
const channelCount = channels && channels.length;
|
|
||||||
const resolvingCount = resolvingUris && resolvingUris.length;
|
|
||||||
|
|
||||||
const topChannel =
|
const topChannel =
|
||||||
channels &&
|
channels &&
|
||||||
channels.reduce((top, channel) => {
|
channels.reduce((top, channel) => {
|
||||||
|
@ -70,27 +58,12 @@ function InviteNew(props: Props) {
|
||||||
|
|
||||||
const referral = `${URL}/$/invite/${referralString.replace('#', ':')}`;
|
const referral = `${URL}/$/invite/${referralString.replace('#', ':')}`;
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// resolve once, after we have channel list
|
|
||||||
if (!hasResolved && !resolveStarted && channelCount && uris) {
|
|
||||||
setResolveStarted(true);
|
|
||||||
resolveUris(uris.split(','));
|
|
||||||
}
|
|
||||||
}, [channelCount, resolveStarted, hasResolved, resolvingCount, uris]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// once resolving count is 0, we know we're done
|
|
||||||
if (resolveStarted && !hasResolved && resolvingCount === 0) {
|
|
||||||
setHasResolved(true);
|
|
||||||
}
|
|
||||||
}, [resolveStarted, hasResolved, resolvingCount]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// set default channel
|
// set default channel
|
||||||
if (topChannel && hasResolved) {
|
if (topChannel) {
|
||||||
handleReferralChange(topChannel.name);
|
handleReferralChange(topChannel.name);
|
||||||
}
|
}
|
||||||
}, [topChannel, hasResolved]);
|
}, [topChannel]);
|
||||||
|
|
||||||
function lookupUrlByClaimName(name, channels) {
|
function lookupUrlByClaimName(name, channels) {
|
||||||
const claim = channels.find(channel => channel.name === name);
|
const claim = channels.find(channel => channel.name === name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue