diff --git a/ui/component/claimListDiscover/view.jsx b/ui/component/claimListDiscover/view.jsx index 6ec38e64f..2f929b22c 100644 --- a/ui/component/claimListDiscover/view.jsx +++ b/ui/component/claimListDiscover/view.jsx @@ -21,6 +21,7 @@ import { useIsLargeScreen } from 'effects/use-screensize'; type Props = { uris: Array, prefixUris?: Array, + pins?: { urls: Array, onlyPinForOrder?: string }, name?: string, type: string, pageSize?: number, @@ -139,6 +140,7 @@ function ClaimListDiscover(props: Props) { feeAmount, uris, prefixUris, + pins, tileLayout, hideFilters = false, claimIds, @@ -466,6 +468,7 @@ function ClaimListDiscover(props: Props) { ); const renderUris = uris || claimSearchResult; + injectPinUrls(renderUris, orderParam, pins); // ************************************************************************** // Helpers @@ -527,6 +530,25 @@ function ClaimListDiscover(props: Props) { return order_by; } + function injectPinUrls(uris, order, pins) { + if (!pins || !pins.urls || (pins.onlyPinForOrder && pins.onlyPinForOrder !== order)) { + return; + } + + const pinUrls = pins.urls; + if (pinUrls && uris && uris.length > 2) { + pinUrls.forEach((pin) => { + if (uris.includes(pin)) { + uris.splice(uris.indexOf(pin), 1); + } else { + uris.pop(); + } + }); + + uris.splice(2, 0, ...pinUrls); + } + } + // ************************************************************************** // ************************************************************************** diff --git a/ui/page/discover/view.jsx b/ui/page/discover/view.jsx index bc103d652..015adaf55 100644 --- a/ui/page/discover/view.jsx +++ b/ui/page/discover/view.jsx @@ -28,6 +28,8 @@ const SECTION = { }; type Props = { + dynamicRouteProps: RowDataItem, + // --- redux --- location: { search: string }, followedTags: Array, repostedUri: string, @@ -35,7 +37,6 @@ type Props = { doToggleTagFollowDesktop: (string) => void, doResolveUri: (string) => void, isAuthenticated: boolean, - dynamicRouteProps: RowDataItem, tileLayout: boolean, activeLivestreams: ?LivestreamInfo, doFetchActiveLivestreams: (orderBy?: Array, pageSize?: number, forceFetch?: boolean) => void, @@ -130,6 +131,15 @@ function DiscoverPage(props: Props) { return isLargeScreen ? originalSize * (3 / 2) : originalSize; } + function getPins(routeProps) { + if (routeProps && routeProps.pinnedUrls) { + return { + urls: routeProps.pinnedUrls, + onlyPinForOrder: CS.ORDER_BY_TRENDING, + }; + } + } + React.useEffect(() => { if (repostedUri && !repostedClaimIsResolved) { doResolveUri(repostedUri); @@ -222,6 +232,7 @@ function DiscoverPage(props: Props) { : repostedUri ? : undefined}