lbry-desktop/web/component/youtubeReferralWelcome/view.jsx
jessop e3c2919373 rename lbrytv to web
language and API consts

improve customization
custom homepages
get config from .env.default
custom title and logo

small changes

add pinned item to sidebar

rebase?
2020-05-25 17:21:02 -04:00

25 lines
814 B
JavaScript

// @flow
import * as MODALS from 'constants/modal_types';
import React from 'react';
import usePersistedState from 'effects/use-persisted-state';
type Props = { doOpenModal: string => void, user: ?User };
const YoutubeWelcome = (props: Props) => {
const { doOpenModal, user } = props;
const [hasBeenShownIntro, setHasBeenShownIntro] = usePersistedState('youtube-welcome', false);
const isYouTubeReferrer = document.referrer.includes('youtube.com');
const shouldShowWelcome = !hasBeenShownIntro && isYouTubeReferrer && user && !user.has_verified_email;
React.useEffect(() => {
if (shouldShowWelcome) {
doOpenModal(MODALS.YOUTUBE_WELCOME);
setHasBeenShownIntro(true);
}
}, [shouldShowWelcome, setHasBeenShownIntro, doOpenModal]);
return null;
};
export default YoutubeWelcome;