From f4d327f1f4187b4518c0cd2452397c024c7cdbdc Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Sat, 19 Jun 2021 00:02:36 +0800 Subject: [PATCH] Set 'activeChannel' before entering Dashboard ## Issue 6237: Analytics button from Channels page doesn't open analytics to right channel --- ui/page/channels/index.js | 6 ++++-- ui/page/channels/view.jsx | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ui/page/channels/index.js b/ui/page/channels/index.js index edd3cb134..a2f9321ab 100644 --- a/ui/page/channels/index.js +++ b/ui/page/channels/index.js @@ -5,18 +5,20 @@ import { doFetchChannelListMine, selectFetchingMyChannels, } from 'lbry-redux'; +import { doSetActiveChannel } from 'redux/actions/app'; import { selectYoutubeChannels } from 'redux/selectors/user'; import ChannelsPage from './view'; -const select = state => ({ +const select = (state) => ({ channelUrls: selectMyChannelUrls(state), channels: selectMyChannelClaims(state), fetchingChannels: selectFetchingMyChannels(state), youtubeChannels: selectYoutubeChannels(state), }); -const perform = dispatch => ({ +const perform = (dispatch) => ({ fetchChannelListMine: () => dispatch(doFetchChannelListMine()), + doSetActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)), }); export default connect(select, perform)(ChannelsPage); diff --git a/ui/page/channels/view.jsx b/ui/page/channels/view.jsx index fbe1f4704..aa4e41c52 100644 --- a/ui/page/channels/view.jsx +++ b/ui/page/channels/view.jsx @@ -11,6 +11,7 @@ import Yrbl from 'component/yrbl'; import LbcSymbol from 'component/common/lbc-symbol'; import * as PAGES from 'constants/pages'; import HelpLink from 'component/common/help-link'; +import { useHistory } from 'react-router'; type Props = { channels: Array, @@ -18,13 +19,15 @@ type Props = { fetchChannelListMine: () => void, fetchingChannels: boolean, youtubeChannels: ?Array, + doSetActiveChannel: (string) => void, }; export default function ChannelsPage(props: Props) { - const { channels, channelUrls, fetchChannelListMine, fetchingChannels, youtubeChannels } = props; + const { channels, channelUrls, fetchChannelListMine, fetchingChannels, youtubeChannels, doSetActiveChannel } = props; const [rewardData, setRewardData] = React.useState(); const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length); const hasPendingChannels = channels && channels.some((channel) => channel.confirmations < 0); + const { push } = useHistory(); useEffect(() => { fetchChannelListMine(); @@ -62,7 +65,10 @@ export default function ChannelsPage(props: Props) { button="alt" icon={ICONS.ANALYTICS} label={__('Analytics')} - navigate={`/$/${PAGES.CREATOR_DASHBOARD}?channel=${encodeURIComponent(claim.canonical_url)}`} + onClick={() => { + doSetActiveChannel(claim.claim_id); + push(`/$/${PAGES.CREATOR_DASHBOARD}`); + }} /> );