Merge pull request #4963 from lbryio/feat-userIconIdentity

make header user icon reflect comment identity
This commit is contained in:
jessopb 2020-10-29 08:27:34 -04:00 committed by GitHub
commit 54466edafc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -7,6 +7,7 @@ import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user';
import { doSetClientSetting } from 'redux/actions/settings';
import { doSignOut, doOpenModal } from 'redux/actions/app';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { selectCommentChannel } from 'redux/selectors/comments';
import Header from './view';
import { selectHasNavigated } from 'redux/selectors/app';
@ -24,6 +25,7 @@ const select = state => ({
hasNavigated: selectHasNavigated(state),
user: selectUser(state),
myChannels: selectMyChannelClaims(state),
commentChannel: selectCommentChannel(state),
});
const perform = dispatch => ({

View file

@ -61,6 +61,7 @@ type Props = {
isAbsoluteSideNavHidden: boolean,
hideCancel: boolean,
myChannels: ?Array<ChannelClaim>,
commentChannel: string,
};
const Header = (props: Props) => {
@ -87,6 +88,7 @@ const Header = (props: Props) => {
user,
hideCancel,
myChannels,
commentChannel,
} = props;
const isMobile = useIsMobile();
// on the verify page don't let anyone escape other than by closing the tab to keep session data consistent
@ -98,9 +100,16 @@ const Header = (props: Props) => {
const { backLabel, backNavDefault, title: backTitle, simpleTitle: simpleBackTitle } = backout || {};
const notificationsEnabled = user && user.experimental_ui;
let channelUrl;
if (myChannels && myChannels.length === 1) {
const channel = myChannels[0];
channelUrl = channel.permanent_url || channel.canonical_url;
let identityChannel;
if (myChannels && myChannels.length > 1) {
if (myChannels.length === 1) {
identityChannel = myChannels[0];
} else if (commentChannel) {
identityChannel = myChannels.find(chan => chan.name === commentChannel);
} else {
identityChannel = myChannels[0];
}
channelUrl = identityChannel && (identityChannel.permanent_url || identityChannel.canonical_url);
}
// Sign out if they click the "x" when they are on the password prompt
const authHeaderAction = syncError ? { onClick: signOut } : { navigate: '/' };