fix multiple channels analytics bug
This commit is contained in:
parent
32d624b807
commit
3a6bddc588
4 changed files with 21 additions and 7 deletions
|
@ -1,10 +1,11 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectMyChannelClaims } from 'lbry-redux';
|
import { selectMyChannelClaims, makeSelectClaimForUri } from 'lbry-redux';
|
||||||
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
|
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
|
||||||
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
|
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
|
||||||
import SelectChannel from './view';
|
import SelectChannel from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = (state, props) => ({
|
||||||
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
channels: selectMyChannelClaims(state),
|
channels: selectMyChannelClaims(state),
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
incognito: selectIncognito(state),
|
incognito: selectIncognito(state),
|
||||||
|
|
|
@ -10,6 +10,8 @@ import Icon from 'component/common/icon';
|
||||||
import { useHistory } from 'react-router';
|
import { useHistory } from 'react-router';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
uri: string,
|
||||||
|
claim: ?Claim,
|
||||||
selectedChannelUrl: string, // currently selected channel
|
selectedChannelUrl: string, // currently selected channel
|
||||||
channels: ?Array<ChannelClaim>,
|
channels: ?Array<ChannelClaim>,
|
||||||
onChannelSelect: (url: string) => void,
|
onChannelSelect: (url: string) => void,
|
||||||
|
@ -18,6 +20,8 @@ type Props = {
|
||||||
doSetActiveChannel: (string) => void,
|
doSetActiveChannel: (string) => void,
|
||||||
incognito: boolean,
|
incognito: boolean,
|
||||||
doSetIncognito: (boolean) => void,
|
doSetIncognito: (boolean) => void,
|
||||||
|
activeChanged: boolean,
|
||||||
|
setActiveChanged: (boolean) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
type ListItemProps = {
|
type ListItemProps = {
|
||||||
|
@ -52,15 +56,19 @@ function IncognitoSelector(props: IncognitoSelectorProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChannelSelector(props: Props) {
|
function ChannelSelector(props: Props) {
|
||||||
const { channels, activeChannelClaim, doSetActiveChannel, hideAnon = false, incognito, doSetIncognito } = props;
|
const { claim, channels, activeChannelClaim, doSetActiveChannel, hideAnon = false, incognito, doSetIncognito, activeChanged, setActiveChanged } = props;
|
||||||
const {
|
const {
|
||||||
push,
|
push,
|
||||||
location: { pathname },
|
location: { pathname },
|
||||||
} = useHistory();
|
} = useHistory();
|
||||||
|
const selectedClaimId = claim && claim.claim_id;
|
||||||
|
if (selectedClaimId && !activeChanged) doSetActiveChannel(selectedClaimId);
|
||||||
|
|
||||||
const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
|
const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
|
||||||
|
|
||||||
function handleChannelSelect(channelClaim) {
|
function handleChannelSelect(channelClaim) {
|
||||||
doSetIncognito(false);
|
doSetIncognito(false);
|
||||||
|
setActiveChanged(true);
|
||||||
doSetActiveChannel(channelClaim.claim_id);
|
doSetActiveChannel(channelClaim.claim_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ function ClaimMenuList(props: Props) {
|
||||||
} = props;
|
} = props;
|
||||||
const incognito = channelUri && !(channelUri.includes('@'));
|
const incognito = channelUri && !(channelUri.includes('@'));
|
||||||
const signingChannel = claim && (claim.signing_channel || claim);
|
const signingChannel = claim && (claim.signing_channel || claim);
|
||||||
|
const permanentUrl = signingChannel && signingChannel.permanent_url;
|
||||||
const isChannel = !incognito && signingChannel === claim;
|
const isChannel = !incognito && signingChannel === claim;
|
||||||
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
|
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
|
||||||
const subscriptionLabel = isSubscribed ? __('Unfollow') : __('Follow');
|
const subscriptionLabel = isSubscribed ? __('Unfollow') : __('Follow');
|
||||||
|
@ -100,7 +101,6 @@ function ClaimMenuList(props: Props) {
|
||||||
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video');
|
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video');
|
||||||
|
|
||||||
function handleFollow() {
|
function handleFollow() {
|
||||||
const permanentUrl = signingChannel && signingChannel.permanent_url;
|
|
||||||
const { channelName } = parseURI(permanentUrl);
|
const { channelName } = parseURI(permanentUrl);
|
||||||
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ function ClaimMenuList(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnalytics() {
|
function handleAnalytics() {
|
||||||
push(`/$/${PAGES.CREATOR_DASHBOARD}?channel=${encodeURIComponent(signingChannel.canonical_url)}`);
|
push(`/$/${PAGES.CREATOR_DASHBOARD}?channel=${encodeURIComponent(permanentUrl)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleToggleMute() {
|
function handleToggleMute() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Button from 'component/button';
|
||||||
import CreatorAnalytics from 'component/creatorAnalytics';
|
import CreatorAnalytics from 'component/creatorAnalytics';
|
||||||
import ChannelSelector from 'component/channelSelector';
|
import ChannelSelector from 'component/channelSelector';
|
||||||
import Yrbl from 'component/yrbl';
|
import Yrbl from 'component/yrbl';
|
||||||
|
import { useHistory } from 'react-router';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
channels: Array<ChannelClaim>,
|
channels: Array<ChannelClaim>,
|
||||||
|
@ -17,6 +18,10 @@ type Props = {
|
||||||
export default function CreatorDashboardPage(props: Props) {
|
export default function CreatorDashboardPage(props: Props) {
|
||||||
const { channels, fetchingChannels, activeChannelClaim } = props;
|
const { channels, fetchingChannels, activeChannelClaim } = props;
|
||||||
const hasChannels = channels && channels.length > 0;
|
const hasChannels = channels && channels.length > 0;
|
||||||
|
const [activeChanged, setActiveChanged] = React.useState(false);
|
||||||
|
const { location: { search } } = useHistory();
|
||||||
|
const urlParams = new URLSearchParams(search);
|
||||||
|
const channelParam = urlParams.get('channel');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
@ -40,8 +45,8 @@ export default function CreatorDashboardPage(props: Props) {
|
||||||
|
|
||||||
{!fetchingChannels && activeChannelClaim && (
|
{!fetchingChannels && activeChannelClaim && (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<ChannelSelector hideAnon />
|
<ChannelSelector hideAnon uri={channelParam} activeChanged={activeChanged} setActiveChanged={setActiveChanged} />
|
||||||
<CreatorAnalytics uri={activeChannelClaim.canonical_url} />
|
<CreatorAnalytics uri={!activeChanged && channelParam ? channelParam : activeChannelClaim.canonical_url} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</Page>
|
</Page>
|
||||||
|
|
Loading…
Reference in a new issue