Show view counts on uploads page
## Ticket 556
This commit is contained in:
parent
87e4fa5c6c
commit
06bfe60c54
3 changed files with 19 additions and 5 deletions
|
@ -1,11 +1,12 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import 'scss/component/_view_count.scss';
|
import 'scss/component/_view_count.scss';
|
||||||
|
import * as PAGES from 'constants/pages';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
isLivestream?: boolean,
|
isLivestream?: boolean,
|
||||||
// --- select ---
|
// --- redux ---
|
||||||
claim: ?StreamClaim,
|
claim: ?StreamClaim,
|
||||||
viewCount: string,
|
viewCount: string,
|
||||||
lang: ?string,
|
lang: ?string,
|
||||||
|
@ -24,16 +25,18 @@ export default function FileViewCountInline(props: Props) {
|
||||||
formattedViewCount = Number(viewCount).toLocaleString();
|
formattedViewCount = Number(viewCount).toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit the view-count visibility to Channel Pages for now. We'll eventually
|
// Limit the view-count visibility to specific pages for now. We'll eventually
|
||||||
// show it everywhere, so this band-aid would be the easiest to clean up
|
// show it everywhere, so this band-aid would be the easiest to clean up
|
||||||
// (only one place edit/remove).
|
// (only one place edit/remove).
|
||||||
const pathname: string = window.location.pathname;
|
const pathname: string = window.location.pathname;
|
||||||
const isOnChannelPage = pathname && pathname.startsWith('/@') && pathname.indexOf('/', 1) === -1;
|
const isOnAllowedPage =
|
||||||
|
(pathname && pathname.startsWith('/@') && pathname.indexOf('/', 1) === -1) || // Channel Page
|
||||||
|
pathname === `/$/${PAGES.UPLOADS}`;
|
||||||
|
|
||||||
if (!viewCount || (claim && claim.repost_url) || isLivestream || !isOnChannelPage) {
|
if (!viewCount || (claim && claim.repost_url) || isLivestream || !isOnAllowedPage) {
|
||||||
// (1) Currently, selectViewCountForUri doesn't differentiate between
|
// (1) Currently, selectViewCountForUri doesn't differentiate between
|
||||||
// un-fetched vs zero view-count. But since it's probably not ideal to
|
// un-fetched vs zero view-count. But since it's probably not ideal to
|
||||||
// highlight that a claim has 0 count, let's just not show anything.
|
// highlight that a claim has 0 view count, let's just not show anything.
|
||||||
// (2) No idea how to get the repost source's claim ID from the repost claim,
|
// (2) No idea how to get the repost source's claim ID from the repost claim,
|
||||||
// so hiding it for now.
|
// so hiding it for now.
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -4,10 +4,12 @@ import {
|
||||||
selectMyClaimsPage,
|
selectMyClaimsPage,
|
||||||
selectMyClaimsPageItemCount,
|
selectMyClaimsPageItemCount,
|
||||||
selectFetchingMyClaimsPageError,
|
selectFetchingMyClaimsPageError,
|
||||||
|
selectClaimsByUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { selectUploadCount } from 'redux/selectors/publish';
|
import { selectUploadCount } from 'redux/selectors/publish';
|
||||||
import { doFetchClaimListMine, doCheckPendingClaims } from 'redux/actions/claims';
|
import { doFetchClaimListMine, doCheckPendingClaims } from 'redux/actions/claims';
|
||||||
import { doClearPublish } from 'redux/actions/publish';
|
import { doClearPublish } from 'redux/actions/publish';
|
||||||
|
import { doFetchViewCount } from 'lbryinc';
|
||||||
import FileListPublished from './view';
|
import FileListPublished from './view';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import { MY_CLAIMS_PAGE_SIZE, PAGE_PARAM, PAGE_SIZE_PARAM } from 'constants/claim';
|
import { MY_CLAIMS_PAGE_SIZE, PAGE_PARAM, PAGE_SIZE_PARAM } from 'constants/claim';
|
||||||
|
@ -26,6 +28,7 @@ const select = (state, props) => {
|
||||||
urlTotal: selectMyClaimsPageItemCount(state),
|
urlTotal: selectMyClaimsPageItemCount(state),
|
||||||
error: selectFetchingMyClaimsPageError(state),
|
error: selectFetchingMyClaimsPageError(state),
|
||||||
uploadCount: selectUploadCount(state),
|
uploadCount: selectUploadCount(state),
|
||||||
|
claimsByUri: selectClaimsByUri(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +37,7 @@ const perform = (dispatch) => ({
|
||||||
fetchClaimListMine: (page, pageSize, resolve, filterBy) =>
|
fetchClaimListMine: (page, pageSize, resolve, filterBy) =>
|
||||||
dispatch(doFetchClaimListMine(page, pageSize, resolve, filterBy)),
|
dispatch(doFetchClaimListMine(page, pageSize, resolve, filterBy)),
|
||||||
clearPublish: () => dispatch(doClearPublish()),
|
clearPublish: () => dispatch(doClearPublish()),
|
||||||
|
doFetchViewCount: (csv) => dispatch(doFetchViewCount(csv)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(connect(select, perform)(FileListPublished));
|
export default withRouter(connect(select, perform)(FileListPublished));
|
||||||
|
|
|
@ -11,6 +11,7 @@ import WebUploadList from 'component/webUploadList';
|
||||||
import Spinner from 'component/spinner';
|
import Spinner from 'component/spinner';
|
||||||
import Yrbl from 'component/yrbl';
|
import Yrbl from 'component/yrbl';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
import useFetchViewCount from 'effects/use-fetch-view-count';
|
||||||
|
|
||||||
const FILTER_ALL = 'stream,repost';
|
const FILTER_ALL = 'stream,repost';
|
||||||
const FILTER_UPLOADS = 'stream';
|
const FILTER_UPLOADS = 'stream';
|
||||||
|
@ -18,6 +19,7 @@ const FILTER_REPOSTS = 'repost';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uploadCount: number,
|
uploadCount: number,
|
||||||
|
claimsByUri: { [string]: any },
|
||||||
checkPendingPublishes: () => void,
|
checkPendingPublishes: () => void,
|
||||||
clearPublish: () => void,
|
clearPublish: () => void,
|
||||||
fetchClaimListMine: (number, number, boolean, Array<string>) => void,
|
fetchClaimListMine: (number, number, boolean, Array<string>) => void,
|
||||||
|
@ -27,11 +29,13 @@ type Props = {
|
||||||
history: { replace: (string) => void, push: (string) => void },
|
history: { replace: (string) => void, push: (string) => void },
|
||||||
page: number,
|
page: number,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
|
doFetchViewCount: (claimIdCsv: string) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function FileListPublished(props: Props) {
|
function FileListPublished(props: Props) {
|
||||||
const {
|
const {
|
||||||
uploadCount,
|
uploadCount,
|
||||||
|
claimsByUri,
|
||||||
checkPendingPublishes,
|
checkPendingPublishes,
|
||||||
clearPublish,
|
clearPublish,
|
||||||
fetchClaimListMine,
|
fetchClaimListMine,
|
||||||
|
@ -40,6 +44,7 @@ function FileListPublished(props: Props) {
|
||||||
urlTotal,
|
urlTotal,
|
||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
doFetchViewCount,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [filterBy, setFilterBy] = React.useState(FILTER_ALL);
|
const [filterBy, setFilterBy] = React.useState(FILTER_ALL);
|
||||||
|
@ -61,6 +66,8 @@ function FileListPublished(props: Props) {
|
||||||
}
|
}
|
||||||
}, [uploadCount, paramsString, filterBy, fetchClaimListMine]);
|
}, [uploadCount, paramsString, filterBy, fetchClaimListMine]);
|
||||||
|
|
||||||
|
useFetchViewCount(!fetching, urls, claimsByUri, doFetchViewCount);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<div className="card-stack">
|
<div className="card-stack">
|
||||||
|
|
Loading…
Reference in a new issue