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

View file

@ -18,21 +18,21 @@ import Button from 'component/button';
type HeaderMenuButtonProps = {
myChannelClaimIds: ?Array<string>,
defaultChannelClaim: ?ChannelClaim,
activeChannelClaim: ?ChannelClaim,
authenticated: boolean,
email: ?string,
signOut: () => void,
};
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 open = Boolean(anchorEl);
const handleClick = (event) => setAnchorEl(!anchorEl ? event.currentTarget : 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 }
const noActiveChannel = activeChannelUrl === null;
const pendingChannelFetch = !noActiveChannel && myChannelClaimIds === undefined;