mvp for 'top' page
This commit is contained in:
parent
5c92c20f51
commit
6a529d55ba
11 changed files with 110 additions and 17 deletions
|
@ -30,6 +30,7 @@ type Props = {
|
||||||
showHiddenByUser: boolean,
|
showHiddenByUser: boolean,
|
||||||
headerLabel?: string | Node,
|
headerLabel?: string | Node,
|
||||||
showUnresolvedClaims?: boolean,
|
showUnresolvedClaims?: boolean,
|
||||||
|
renderProperties: ?(Claim) => Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ClaimList(props: Props) {
|
export default function ClaimList(props: Props) {
|
||||||
|
@ -49,6 +50,7 @@ export default function ClaimList(props: Props) {
|
||||||
showHiddenByUser,
|
showHiddenByUser,
|
||||||
headerLabel,
|
headerLabel,
|
||||||
showUnresolvedClaims,
|
showUnresolvedClaims,
|
||||||
|
renderProperties,
|
||||||
} = props;
|
} = props;
|
||||||
const [scrollBottomCbMap, setScrollBottomCbMap] = useState({});
|
const [scrollBottomCbMap, setScrollBottomCbMap] = useState({});
|
||||||
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
|
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
|
||||||
|
@ -133,7 +135,7 @@ export default function ClaimList(props: Props) {
|
||||||
uri={uri}
|
uri={uri}
|
||||||
type={type}
|
type={type}
|
||||||
showUnresolvedClaim={showUnresolvedClaims}
|
showUnresolvedClaim={showUnresolvedClaims}
|
||||||
properties={type !== 'small' ? undefined : false}
|
properties={renderProperties || (type !== 'small' ? undefined : false)}
|
||||||
showUserBlocked={showHiddenByUser}
|
showUserBlocked={showHiddenByUser}
|
||||||
customShouldHide={(claim: StreamClaim) => {
|
customShouldHide={(claim: StreamClaim) => {
|
||||||
// Hack to hide spee.ch thumbnail publishes
|
// Hack to hide spee.ch thumbnail publishes
|
||||||
|
|
|
@ -13,11 +13,11 @@ import { toCapitalCase } from 'util/string';
|
||||||
import I18nMessage from 'component/i18nMessage';
|
import I18nMessage from 'component/i18nMessage';
|
||||||
|
|
||||||
const PAGE_SIZE = 20;
|
const PAGE_SIZE = 20;
|
||||||
const TIME_DAY = 'day';
|
export const TIME_DAY = 'day';
|
||||||
const TIME_WEEK = 'week';
|
export const TIME_WEEK = 'week';
|
||||||
const TIME_MONTH = 'month';
|
export const TIME_MONTH = 'month';
|
||||||
const TIME_YEAR = 'year';
|
export const TIME_YEAR = 'year';
|
||||||
const TIME_ALL = 'all';
|
export const TIME_ALL = 'all';
|
||||||
|
|
||||||
export const TYPE_TRENDING = 'trending';
|
export const TYPE_TRENDING = 'trending';
|
||||||
export const TYPE_TOP = 'top';
|
export const TYPE_TOP = 'top';
|
||||||
|
@ -45,7 +45,12 @@ type Props = {
|
||||||
hiddenNsfwMessage?: Node,
|
hiddenNsfwMessage?: Node,
|
||||||
channelIds?: Array<string>,
|
channelIds?: Array<string>,
|
||||||
defaultTypeSort?: string,
|
defaultTypeSort?: string,
|
||||||
|
defaultTimeSort?: string,
|
||||||
|
defaultOrderBy?: Array<string>,
|
||||||
|
header?: Node,
|
||||||
headerLabel?: string | Node,
|
headerLabel?: string | Node,
|
||||||
|
name?: string,
|
||||||
|
renderProperties?: Claim => Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ClaimListDiscover(props: Props) {
|
function ClaimListDiscover(props: Props) {
|
||||||
|
@ -63,7 +68,12 @@ function ClaimListDiscover(props: Props) {
|
||||||
hiddenUris,
|
hiddenUris,
|
||||||
hiddenNsfwMessage,
|
hiddenNsfwMessage,
|
||||||
defaultTypeSort,
|
defaultTypeSort,
|
||||||
|
defaultTimeSort,
|
||||||
|
defaultOrderBy,
|
||||||
headerLabel,
|
headerLabel,
|
||||||
|
header,
|
||||||
|
name,
|
||||||
|
renderProperties,
|
||||||
} = props;
|
} = props;
|
||||||
const didNavigateForward = history.action === 'PUSH';
|
const didNavigateForward = history.action === 'PUSH';
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
|
@ -71,7 +81,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
const [forceRefresh, setForceRefresh] = useState();
|
const [forceRefresh, setForceRefresh] = useState();
|
||||||
const urlParams = new URLSearchParams(search);
|
const urlParams = new URLSearchParams(search);
|
||||||
const typeSort = urlParams.get('type') || defaultTypeSort || TYPE_TRENDING;
|
const typeSort = urlParams.get('type') || defaultTypeSort || TYPE_TRENDING;
|
||||||
const timeSort = urlParams.get('time') || TIME_WEEK;
|
const timeSort = urlParams.get('time') || defaultTimeSort || TIME_WEEK;
|
||||||
const tagsInUrl = urlParams.get('t') || '';
|
const tagsInUrl = urlParams.get('t') || '';
|
||||||
const options: {
|
const options: {
|
||||||
page_size: number,
|
page_size: number,
|
||||||
|
@ -83,9 +93,11 @@ function ClaimListDiscover(props: Props) {
|
||||||
not_tags: Array<string>,
|
not_tags: Array<string>,
|
||||||
order_by: Array<string>,
|
order_by: Array<string>,
|
||||||
release_time?: string,
|
release_time?: string,
|
||||||
|
name?: string,
|
||||||
} = {
|
} = {
|
||||||
page_size: PAGE_SIZE,
|
page_size: PAGE_SIZE,
|
||||||
page,
|
page,
|
||||||
|
name,
|
||||||
// no_totals makes it so the sdk doesn't have to calculate total number pages for pagination
|
// no_totals makes it so the sdk doesn't have to calculate total number pages for pagination
|
||||||
// it's faster, but we will need to remove it if we start using total_pages
|
// it's faster, but we will need to remove it if we start using total_pages
|
||||||
no_totals: true,
|
no_totals: true,
|
||||||
|
@ -96,11 +108,12 @@ function ClaimListDiscover(props: Props) {
|
||||||
!channelIds && hiddenUris && hiddenUris.length ? hiddenUris.map(hiddenUri => hiddenUri.split('#')[1]) : [],
|
!channelIds && hiddenUris && hiddenUris.length ? hiddenUris.map(hiddenUri => hiddenUri.split('#')[1]) : [],
|
||||||
not_tags: !showNsfw ? MATURE_TAGS : [],
|
not_tags: !showNsfw ? MATURE_TAGS : [],
|
||||||
order_by:
|
order_by:
|
||||||
typeSort === TYPE_TRENDING
|
defaultOrderBy ||
|
||||||
|
(typeSort === TYPE_TRENDING
|
||||||
? ['trending_group', 'trending_mixed']
|
? ['trending_group', 'trending_mixed']
|
||||||
: typeSort === TYPE_NEW
|
: typeSort === TYPE_NEW
|
||||||
? ['release_time']
|
? ['release_time']
|
||||||
: ['effective_amount'], // Sort by top
|
: ['effective_amount']), // Sort by top
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeSort === TYPE_TOP && timeSort !== TIME_ALL) {
|
if (typeSort === TYPE_TOP && timeSort !== TIME_ALL) {
|
||||||
|
@ -216,7 +229,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
}
|
}
|
||||||
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, forceRefresh]);
|
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, forceRefresh]);
|
||||||
|
|
||||||
const header = (
|
const defaultHeader = (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{SEARCH_TYPES.map(type => (
|
{SEARCH_TYPES.map(type => (
|
||||||
<Button
|
<Button
|
||||||
|
@ -261,13 +274,14 @@ function ClaimListDiscover(props: Props) {
|
||||||
id={claimSearchCacheQuery}
|
id={claimSearchCacheQuery}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
uris={uris}
|
uris={uris}
|
||||||
header={header}
|
header={header || defaultHeader}
|
||||||
headerLabel={headerLabel}
|
headerLabel={headerLabel}
|
||||||
headerAltControls={meta}
|
headerAltControls={meta}
|
||||||
onScrollBottom={handleScrollBottom}
|
onScrollBottom={handleScrollBottom}
|
||||||
page={page}
|
page={page}
|
||||||
pageSize={PAGE_SIZE}
|
pageSize={PAGE_SIZE}
|
||||||
empty={noResults}
|
empty={noResults}
|
||||||
|
renderProperties={renderProperties}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
|
|
@ -49,7 +49,7 @@ type Props = {
|
||||||
channelIsBlocked: boolean,
|
channelIsBlocked: boolean,
|
||||||
isSubscribed: boolean,
|
isSubscribed: boolean,
|
||||||
actions: boolean | Node | string | number,
|
actions: boolean | Node | string | number,
|
||||||
properties: boolean | Node | string | number,
|
properties: boolean | Node | string | number | (Claim => Node),
|
||||||
onClick?: any => any,
|
onClick?: any => any,
|
||||||
hideBlock?: boolean,
|
hideBlock?: boolean,
|
||||||
streamingUrl: ?string,
|
streamingUrl: ?string,
|
||||||
|
@ -205,7 +205,6 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldFetch && showUnresolvedClaim && !isResolvingUri && claim === null) {
|
if (!shouldFetch && showUnresolvedClaim && !isResolvingUri && claim === null) {
|
||||||
return <AbandonedChannelPreview uri={uri} type />;
|
return <AbandonedChannelPreview uri={uri} type />;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +283,17 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
)}
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
{properties !== undefined ? properties : <ClaimTags uri={uri} type={type} />}
|
{claim && (
|
||||||
|
<React.Fragment>
|
||||||
|
{typeof properties === 'function' ? (
|
||||||
|
properties(claim)
|
||||||
|
) : properties !== undefined ? (
|
||||||
|
properties
|
||||||
|
) : (
|
||||||
|
<ClaimTags uri={uri} type={type} />
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,6 +54,10 @@ class FileDetails extends PureComponent<Props> {
|
||||||
<td> {__('Content Type')}</td>
|
<td> {__('Content Type')}</td>
|
||||||
<td>{mediaType}</td>
|
<td>{mediaType}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> {__('Bid Amount')}</td>
|
||||||
|
<td>{claim.amount} LBC</td>
|
||||||
|
</tr>
|
||||||
{fileSize && (
|
{fileSize && (
|
||||||
<tr>
|
<tr>
|
||||||
<td> {__('File Size')}</td>
|
<td> {__('File Size')}</td>
|
||||||
|
|
|
@ -29,6 +29,7 @@ import SignInPage from 'page/signIn';
|
||||||
import SignInVerifyPage from 'page/signInVerify';
|
import SignInVerifyPage from 'page/signInVerify';
|
||||||
import ChannelsPage from 'page/channels';
|
import ChannelsPage from 'page/channels';
|
||||||
import EmbedWrapperPage from 'page/embedWrapper';
|
import EmbedWrapperPage from 'page/embedWrapper';
|
||||||
|
import TopPage from 'page/top';
|
||||||
|
|
||||||
// Tell the browser we are handling scroll restoration
|
// Tell the browser we are handling scroll restoration
|
||||||
if ('scrollRestoration' in history) {
|
if ('scrollRestoration' in history) {
|
||||||
|
@ -98,6 +99,7 @@ function AppRouter(props: Props) {
|
||||||
<Route path={`/$/${PAGES.HELP}`} exact component={HelpPage} />
|
<Route path={`/$/${PAGES.HELP}`} exact component={HelpPage} />
|
||||||
<Route path={`/$/${PAGES.AUTH_VERIFY}`} exact component={SignInVerifyPage} />
|
<Route path={`/$/${PAGES.AUTH_VERIFY}`} exact component={SignInVerifyPage} />
|
||||||
<Route path={`/$/${PAGES.SEARCH}`} exact component={SearchPage} />
|
<Route path={`/$/${PAGES.SEARCH}`} exact component={SearchPage} />
|
||||||
|
<Route path={`/$/${PAGES.TOP}`} exact component={TopPage} />
|
||||||
<Route path={`/$/${PAGES.SETTINGS}`} exact component={SettingsPage} />
|
<Route path={`/$/${PAGES.SETTINGS}`} exact component={SettingsPage} />
|
||||||
<Route path={`/$/${PAGES.INVITE}/:referrer`} exact component={InvitedPage} />
|
<Route path={`/$/${PAGES.INVITE}/:referrer`} exact component={InvitedPage} />
|
||||||
|
|
||||||
|
|
|
@ -28,3 +28,4 @@ exports.WALLET = 'wallet';
|
||||||
exports.BLOCKED = 'blocked';
|
exports.BLOCKED = 'blocked';
|
||||||
exports.CHANNELS = 'channels';
|
exports.CHANNELS = 'channels';
|
||||||
exports.EMBED = 'embed';
|
exports.EMBED = 'embed';
|
||||||
|
exports.TOP = 'top';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as ICONS from 'constants/icons';
|
import * as ICONS from 'constants/icons';
|
||||||
|
import * as PAGES from 'constants/pages';
|
||||||
import React, { useEffect, Fragment } from 'react';
|
import React, { useEffect, Fragment } from 'react';
|
||||||
import { regexInvalidURI } from 'lbry-redux';
|
import { regexInvalidURI } from 'lbry-redux';
|
||||||
import ClaimPreview from 'component/claimPreview';
|
import ClaimPreview from 'component/claimPreview';
|
||||||
|
@ -52,7 +53,18 @@ export default function SearchPage(props: Props) {
|
||||||
{urlQuery && (
|
{urlQuery && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<header className="search__header">
|
<header className="search__header">
|
||||||
<ClaimUri uri={uriFromQuery} />
|
<div className="claim-preview__actions--header">
|
||||||
|
<ClaimUri uri={uriFromQuery} />
|
||||||
|
<Button
|
||||||
|
className="media__uri--right"
|
||||||
|
button="alt"
|
||||||
|
label={__('View top claims for %normalized_uri%', {
|
||||||
|
normalized_uri: uriFromQuery,
|
||||||
|
})}
|
||||||
|
navigate={`/$/${PAGES.TOP}?name=${modifiedUrlQuery}`}
|
||||||
|
icon={ICONS.TOP}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<ClaimPreview uri={uriFromQuery} type="large" placeholder="publish" />
|
<ClaimPreview uri={uriFromQuery} type="large" placeholder="publish" />
|
||||||
</div>
|
</div>
|
||||||
|
|
14
ui/page/top/index.js
Normal file
14
ui/page/top/index.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import TopPage from './view';
|
||||||
|
|
||||||
|
const select = (state, props) => {
|
||||||
|
const { search } = props.location;
|
||||||
|
const urlParams = new URLSearchParams(search);
|
||||||
|
const name = urlParams.get('name');
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(select)(TopPage);
|
28
ui/page/top/view.jsx
Normal file
28
ui/page/top/view.jsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// @flow
|
||||||
|
import React from 'react';
|
||||||
|
import Page from 'component/page';
|
||||||
|
import ClaimListDiscover from 'component/claimListDiscover';
|
||||||
|
import { TYPE_TOP, TIME_ALL } from 'component/claimListDiscover/view';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
name: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
function TopPage(props: Props) {
|
||||||
|
const { name } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Page>
|
||||||
|
<ClaimListDiscover
|
||||||
|
name={name}
|
||||||
|
defaultTypeSort={TYPE_TOP}
|
||||||
|
defaultTimeSort={TIME_ALL}
|
||||||
|
defaultOrderBy={['effective_amount']}
|
||||||
|
renderProperties={claim => <span className="media__subtitle">{claim.meta.effective_amount} LBC</span>}
|
||||||
|
header={<span>{__('Top claims at lbry://%name%', { name })}</span>}
|
||||||
|
/>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TopPage;
|
|
@ -120,8 +120,6 @@
|
||||||
|
|
||||||
.claim-preview--large {
|
.claim-preview--large {
|
||||||
border: none;
|
border: none;
|
||||||
padding: 0;
|
|
||||||
padding: var(--spacing-small);
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
@ -228,6 +226,10 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.claim-preview__actions--header {
|
||||||
|
@extend .claim-preview__actions;
|
||||||
|
}
|
||||||
|
|
||||||
.claim-preview__button {
|
.claim-preview__button {
|
||||||
margin-left: 2rem;
|
margin-left: 2rem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,11 @@
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.media__uri--right {
|
||||||
|
@extend .media__uri;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.media__uri--large {
|
.media__uri--large {
|
||||||
margin-bottom: var(--spacing-medium);
|
margin-bottom: var(--spacing-medium);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue