Fix header icon active channel

This commit is contained in:
Rafael 2022-05-09 08:05:29 -03:00 committed by Thomas Zarebczan
parent 86819b6876
commit adc3c06803
2 changed files with 8 additions and 8 deletions

View file

@ -1,19 +1,19 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doSignOut } from 'redux/actions/app'; import { doSignOut } from 'redux/actions/app';
import { selectDefaultChannelClaim } from 'redux/selectors/settings'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectMyChannelClaimIds } from 'redux/selectors/claims'; import { selectMyChannelClaimIds } from 'redux/selectors/claims';
import { selectUserEmail, selectUserVerifiedEmail } 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) => ({
myChannelClaimIds: selectMyChannelClaimIds(state), myChannelClaimIds: selectMyChannelClaimIds(state),
defaultChannelClaim: selectDefaultChannelClaim(state), activeChannelClaim: selectActiveChannelClaim(state),
authenticated: selectUserVerifiedEmail(state), authenticated: selectUserVerifiedEmail(state),
email: selectUserEmail(state), email: selectUserEmail(state),
}); });
const perform = (dispatch) => ({ const perform = {
signOut: () => dispatch(doSignOut()), signOut: doSignOut,
}); };
export default connect(select, perform)(HeaderProfileMenuButton); export default connect(select, perform)(HeaderProfileMenuButton);

View file

@ -18,21 +18,21 @@ import Button from 'component/button';
type HeaderMenuButtonProps = { type HeaderMenuButtonProps = {
myChannelClaimIds: ?Array<string>, myChannelClaimIds: ?Array<string>,
defaultChannelClaim: ?ChannelClaim, activeChannelClaim: ?ChannelClaim,
authenticated: boolean, authenticated: boolean,
email: ?string, email: ?string,
signOut: () => void, signOut: () => void,
}; };
export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) { export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
const { myChannelClaimIds, defaultChannelClaim, authenticated, email, signOut } = props; const { myChannelClaimIds, activeChannelClaim, authenticated, email, signOut } = props;
const [anchorEl, setAnchorEl] = React.useState(null); const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const handleClick = (event) => setAnchorEl(!anchorEl ? event.currentTarget : null); const handleClick = (event) => setAnchorEl(!anchorEl ? event.currentTarget : null);
const handleClose = () => setAnchorEl(null); const handleClose = () => setAnchorEl(null);
const activeChannelUrl = defaultChannelClaim && defaultChannelClaim.permanent_url; const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
// activeChannel will be: undefined = fetching, null = nothing, or { channel claim } // activeChannel will be: undefined = fetching, null = nothing, or { channel claim }
const noActiveChannel = activeChannelUrl === null; const noActiveChannel = activeChannelUrl === null;
const pendingChannelFetch = !noActiveChannel && myChannelClaimIds === undefined; const pendingChannelFetch = !noActiveChannel && myChannelClaimIds === undefined;