Fix: account header doesn't refresh on sign up / log in (#629)

## Issue
Closes 627 account header doesn't refresh on sign up / log in

## Changes
Looking back at "[Header] Changes, fixes and improvements (#493)", noticed that old code was looking at `has_verified_email` instead of just checking whether an email exists. So, restored original code.

This does have a side-effect of the Logout button not showing any email address underneath it immediately after sign up (with the flow cancelled). But I vaguely recall it was that way previously. A refresh cleans it up.

Perhaps another `user/me` when leaving the Sign Up page can make everything in sync, but this PR simpler to test.
This commit is contained in:
infinite-persistence 2022-01-05 18:56:17 -08:00 committed by GitHub
parent 96c3b727fe
commit a4d2c6b0a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -1,11 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doSignOut } from 'redux/actions/app'; import { doSignOut } from 'redux/actions/app';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectUserEmail } from 'redux/selectors/user'; import { selectUserEmail, selectUserVerifiedEmail } from 'redux/selectors/user';
import HeaderProfileMenuButton from './view'; import HeaderProfileMenuButton from './view';
const select = (state) => ({ const select = (state) => ({
activeChannelClaim: selectActiveChannelClaim(state), activeChannelClaim: selectActiveChannelClaim(state),
authenticated: selectUserVerifiedEmail(state),
email: selectUserEmail(state), email: selectUserEmail(state),
}); });

View file

@ -13,12 +13,13 @@ import Skeleton from '@mui/material/Skeleton';
type HeaderMenuButtonProps = { type HeaderMenuButtonProps = {
activeChannelClaim: ?ChannelClaim, activeChannelClaim: ?ChannelClaim,
authenticated: boolean,
email: ?string, email: ?string,
signOut: () => void, signOut: () => void,
}; };
export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) { export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
const { activeChannelClaim, email, signOut } = props; const { activeChannelClaim, authenticated, email, signOut } = props;
const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url; const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
@ -45,7 +46,7 @@ export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
)} )}
<MenuList className="menu__list--header"> <MenuList className="menu__list--header">
{email ? ( {authenticated ? (
<> <>
<HeaderMenuLink page={PAGES.UPLOADS} icon={ICONS.PUBLISH} name={__('Uploads')} /> <HeaderMenuLink page={PAGES.UPLOADS} icon={ICONS.PUBLISH} name={__('Uploads')} />
<HeaderMenuLink page={PAGES.CHANNELS} icon={ICONS.CHANNEL} name={__('Channels')} /> <HeaderMenuLink page={PAGES.CHANNELS} icon={ICONS.CHANNEL} name={__('Channels')} />