From 6a529d55baf37a8e2396e3b20bad4bc94f1978f6 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 11 Feb 2020 14:04:51 -0500 Subject: [PATCH] mvp for 'top' page --- ui/component/claimList/view.jsx | 4 ++- ui/component/claimListDiscover/view.jsx | 34 +++++++++++++++++-------- ui/component/claimPreview/view.jsx | 15 ++++++++--- ui/component/fileDetails/view.jsx | 4 +++ ui/component/router/view.jsx | 2 ++ ui/constants/pages.js | 1 + ui/page/search/view.jsx | 14 +++++++++- ui/page/top/index.js | 14 ++++++++++ ui/page/top/view.jsx | 28 ++++++++++++++++++++ ui/scss/component/_claim-list.scss | 6 +++-- ui/scss/component/_media.scss | 5 ++++ 11 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 ui/page/top/index.js create mode 100644 ui/page/top/view.jsx diff --git a/ui/component/claimList/view.jsx b/ui/component/claimList/view.jsx index c4ce9adaf..45ce7eba7 100644 --- a/ui/component/claimList/view.jsx +++ b/ui/component/claimList/view.jsx @@ -30,6 +30,7 @@ type Props = { showHiddenByUser: boolean, headerLabel?: string | Node, showUnresolvedClaims?: boolean, + renderProperties: ?(Claim) => Node, }; export default function ClaimList(props: Props) { @@ -49,6 +50,7 @@ export default function ClaimList(props: Props) { showHiddenByUser, headerLabel, showUnresolvedClaims, + renderProperties, } = props; const [scrollBottomCbMap, setScrollBottomCbMap] = useState({}); const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW); @@ -133,7 +135,7 @@ export default function ClaimList(props: Props) { uri={uri} type={type} showUnresolvedClaim={showUnresolvedClaims} - properties={type !== 'small' ? undefined : false} + properties={renderProperties || (type !== 'small' ? undefined : false)} showUserBlocked={showHiddenByUser} customShouldHide={(claim: StreamClaim) => { // Hack to hide spee.ch thumbnail publishes diff --git a/ui/component/claimListDiscover/view.jsx b/ui/component/claimListDiscover/view.jsx index 525ebd60b..d5afa5124 100644 --- a/ui/component/claimListDiscover/view.jsx +++ b/ui/component/claimListDiscover/view.jsx @@ -13,11 +13,11 @@ import { toCapitalCase } from 'util/string'; import I18nMessage from 'component/i18nMessage'; const PAGE_SIZE = 20; -const TIME_DAY = 'day'; -const TIME_WEEK = 'week'; -const TIME_MONTH = 'month'; -const TIME_YEAR = 'year'; -const TIME_ALL = 'all'; +export const TIME_DAY = 'day'; +export const TIME_WEEK = 'week'; +export const TIME_MONTH = 'month'; +export const TIME_YEAR = 'year'; +export const TIME_ALL = 'all'; export const TYPE_TRENDING = 'trending'; export const TYPE_TOP = 'top'; @@ -45,7 +45,12 @@ type Props = { hiddenNsfwMessage?: Node, channelIds?: Array, defaultTypeSort?: string, + defaultTimeSort?: string, + defaultOrderBy?: Array, + header?: Node, headerLabel?: string | Node, + name?: string, + renderProperties?: Claim => Node, }; function ClaimListDiscover(props: Props) { @@ -63,7 +68,12 @@ function ClaimListDiscover(props: Props) { hiddenUris, hiddenNsfwMessage, defaultTypeSort, + defaultTimeSort, + defaultOrderBy, headerLabel, + header, + name, + renderProperties, } = props; const didNavigateForward = history.action === 'PUSH'; const [page, setPage] = useState(1); @@ -71,7 +81,7 @@ function ClaimListDiscover(props: Props) { const [forceRefresh, setForceRefresh] = useState(); const urlParams = new URLSearchParams(search); 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 options: { page_size: number, @@ -83,9 +93,11 @@ function ClaimListDiscover(props: Props) { not_tags: Array, order_by: Array, release_time?: string, + name?: string, } = { page_size: PAGE_SIZE, page, + name, // 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 no_totals: true, @@ -96,11 +108,12 @@ function ClaimListDiscover(props: Props) { !channelIds && hiddenUris && hiddenUris.length ? hiddenUris.map(hiddenUri => hiddenUri.split('#')[1]) : [], not_tags: !showNsfw ? MATURE_TAGS : [], order_by: - typeSort === TYPE_TRENDING + defaultOrderBy || + (typeSort === TYPE_TRENDING ? ['trending_group', 'trending_mixed'] : typeSort === TYPE_NEW ? ['release_time'] - : ['effective_amount'], // Sort by top + : ['effective_amount']), // Sort by top }; if (typeSort === TYPE_TOP && timeSort !== TIME_ALL) { @@ -216,7 +229,7 @@ function ClaimListDiscover(props: Props) { } }, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, forceRefresh]); - const header = ( + const defaultHeader = ( {SEARCH_TYPES.map(type => (