From ed61ac44bf679134f9eebaf06b3b4dc06c489c18 Mon Sep 17 00:00:00 2001 From: jessop Date: Wed, 28 Oct 2020 17:42:53 -0400 Subject: [PATCH] make header user icon reflect comment identity --- ui/component/header/index.js | 2 ++ ui/component/header/view.jsx | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/component/header/index.js b/ui/component/header/index.js index 9a2864fa0..2becebaa8 100644 --- a/ui/component/header/index.js +++ b/ui/component/header/index.js @@ -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 => ({ diff --git a/ui/component/header/view.jsx b/ui/component/header/view.jsx index d0f3fd689..d4750ef3a 100644 --- a/ui/component/header/view.jsx +++ b/ui/component/header/view.jsx @@ -61,6 +61,7 @@ type Props = { isAbsoluteSideNavHidden: boolean, hideCancel: boolean, myChannels: ?Array, + 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: '/' };