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 ad158bcd93
commit 48073d411b
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 = {
uris: Array<string>,
prefixUris?: Array<string>,
header: Node | boolean,
headerAltControls: Node,
loading: boolean,
@ -49,6 +50,7 @@ export default function ClaimList(props: Props) {
const {
activeUri,
uris,
prefixUris,
headerAltControls,
loading,
persistedStorageKey,
@ -75,10 +77,15 @@ export default function ClaimList(props: Props) {
} = props;
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 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
? __('No results. Contents may be hidden by the Language filter.')
: __('No results');
@ -117,7 +124,7 @@ export default function ClaimList(props: Props) {
return tileLayout && !header ? (
<section className="claim-grid">
{urisLength > 0 &&
uris.map((uri) => (
tileUris.map((uri) => (
<ClaimPreviewTile
key={uri}
uri={uri}

View file

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