ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover

This will be initially used to append livestreams at the top.
This commit is contained in:
infinite-persistence 2021-09-17 17:20:39 +08:00
parent af7345b3cd
commit 14c4be87aa
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 13 additions and 2 deletions

View file

@ -16,6 +16,7 @@ const SORT_OLD = 'old';
type Props = { type Props = {
uris: Array<string>, uris: Array<string>,
prefixUris?: Array<string>,
header: Node | boolean, header: Node | boolean,
headerAltControls: Node, headerAltControls: Node,
loading: boolean, loading: boolean,
@ -49,6 +50,7 @@ export default function ClaimList(props: Props) {
const { const {
activeUri, activeUri,
uris, uris,
prefixUris,
headerAltControls, headerAltControls,
loading, loading,
persistedStorageKey, persistedStorageKey,
@ -75,10 +77,15 @@ export default function ClaimList(props: Props) {
} = props; } = props;
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW); const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
// Exclude prefix uris in these results variables. We don't want to show
// anything if the search failed or timed out.
const timedOut = uris === null; const timedOut = uris === null;
const urisLength = (uris && uris.length) || 0; const urisLength = (uris && uris.length) || 0;
const sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? uris : uris.slice().reverse())) || []; const tileUris = (prefixUris || []).concat(uris);
const sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || [];
const noResultMsg = searchInLanguage const noResultMsg = searchInLanguage
? __('No results. Contents may be hidden by the Language filter.') ? __('No results. Contents may be hidden by the Language filter.')
: __('No results'); : __('No results');
@ -117,7 +124,7 @@ export default function ClaimList(props: Props) {
return tileLayout && !header ? ( return tileLayout && !header ? (
<section className="claim-grid"> <section className="claim-grid">
{urisLength > 0 && {urisLength > 0 &&
uris.map((uri) => ( tileUris.map((uri) => (
<ClaimPreviewTile <ClaimPreviewTile
key={uri} key={uri}
uri={uri} uri={uri}

View file

@ -18,6 +18,7 @@ import { useIsLargeScreen } from 'effects/use-screensize';
type Props = { type Props = {
uris: Array<string>, uris: Array<string>,
prefixUris?: Array<string>,
name?: string, name?: string,
type: string, type: string,
pageSize?: number, pageSize?: number,
@ -135,6 +136,7 @@ function ClaimListDiscover(props: Props) {
injectedItem, injectedItem,
feeAmount, feeAmount,
uris, uris,
prefixUris,
tileLayout, tileLayout,
hideFilters = false, hideFilters = false,
claimIds, claimIds,
@ -569,6 +571,7 @@ function ClaimListDiscover(props: Props) {
tileLayout tileLayout
loading={loading} loading={loading}
uris={renderUris} uris={renderUris}
prefixUris={prefixUris}
onScrollBottom={handleScrollBottom} onScrollBottom={handleScrollBottom}
page={page} page={page}
pageSize={dynamicPageSize} pageSize={dynamicPageSize}
@ -601,6 +604,7 @@ function ClaimListDiscover(props: Props) {
type={type} type={type}
loading={loading} loading={loading}
uris={renderUris} uris={renderUris}
prefixUris={prefixUris}
onScrollBottom={handleScrollBottom} onScrollBottom={handleScrollBottom}
page={page} page={page}
pageSize={dynamicPageSize} pageSize={dynamicPageSize}