Add pinning in Category Pages's Trending Tab (#399)
Closes https://github.com/OdyseeTeam/odysee-homepages/issues/427
This commit is contained in:
parent
6d3ec149b3
commit
7e9e213974
2 changed files with 34 additions and 1 deletions
|
@ -21,6 +21,7 @@ import { useIsLargeScreen } from 'effects/use-screensize';
|
||||||
type Props = {
|
type Props = {
|
||||||
uris: Array<string>,
|
uris: Array<string>,
|
||||||
prefixUris?: Array<string>,
|
prefixUris?: Array<string>,
|
||||||
|
pins?: { urls: Array<string>, onlyPinForOrder?: string },
|
||||||
name?: string,
|
name?: string,
|
||||||
type: string,
|
type: string,
|
||||||
pageSize?: number,
|
pageSize?: number,
|
||||||
|
@ -139,6 +140,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
feeAmount,
|
feeAmount,
|
||||||
uris,
|
uris,
|
||||||
prefixUris,
|
prefixUris,
|
||||||
|
pins,
|
||||||
tileLayout,
|
tileLayout,
|
||||||
hideFilters = false,
|
hideFilters = false,
|
||||||
claimIds,
|
claimIds,
|
||||||
|
@ -466,6 +468,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderUris = uris || claimSearchResult;
|
const renderUris = uris || claimSearchResult;
|
||||||
|
injectPinUrls(renderUris, orderParam, pins);
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// Helpers
|
// Helpers
|
||||||
|
@ -527,6 +530,25 @@ function ClaimListDiscover(props: Props) {
|
||||||
return order_by;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ const SECTION = {
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
dynamicRouteProps: RowDataItem,
|
||||||
|
// --- redux ---
|
||||||
location: { search: string },
|
location: { search: string },
|
||||||
followedTags: Array<Tag>,
|
followedTags: Array<Tag>,
|
||||||
repostedUri: string,
|
repostedUri: string,
|
||||||
|
@ -35,7 +37,6 @@ type Props = {
|
||||||
doToggleTagFollowDesktop: (string) => void,
|
doToggleTagFollowDesktop: (string) => void,
|
||||||
doResolveUri: (string) => void,
|
doResolveUri: (string) => void,
|
||||||
isAuthenticated: boolean,
|
isAuthenticated: boolean,
|
||||||
dynamicRouteProps: RowDataItem,
|
|
||||||
tileLayout: boolean,
|
tileLayout: boolean,
|
||||||
activeLivestreams: ?LivestreamInfo,
|
activeLivestreams: ?LivestreamInfo,
|
||||||
doFetchActiveLivestreams: (orderBy?: Array<string>, pageSize?: number, forceFetch?: boolean) => void,
|
doFetchActiveLivestreams: (orderBy?: Array<string>, pageSize?: number, forceFetch?: boolean) => void,
|
||||||
|
@ -130,6 +131,15 @@ function DiscoverPage(props: Props) {
|
||||||
return isLargeScreen ? originalSize * (3 / 2) : originalSize;
|
return isLargeScreen ? originalSize * (3 / 2) : originalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPins(routeProps) {
|
||||||
|
if (routeProps && routeProps.pinnedUrls) {
|
||||||
|
return {
|
||||||
|
urls: routeProps.pinnedUrls,
|
||||||
|
onlyPinForOrder: CS.ORDER_BY_TRENDING,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (repostedUri && !repostedClaimIsResolved) {
|
if (repostedUri && !repostedClaimIsResolved) {
|
||||||
doResolveUri(repostedUri);
|
doResolveUri(repostedUri);
|
||||||
|
@ -222,6 +232,7 @@ function DiscoverPage(props: Props) {
|
||||||
|
|
||||||
<ClaimListDiscover
|
<ClaimListDiscover
|
||||||
prefixUris={useDualList ? undefined : livestreamUris}
|
prefixUris={useDualList ? undefined : livestreamUris}
|
||||||
|
pins={useDualList ? undefined : getPins(dynamicRouteProps)}
|
||||||
hideAdvancedFilter={SIMPLE_SITE}
|
hideAdvancedFilter={SIMPLE_SITE}
|
||||||
hideFilters={SIMPLE_SITE ? !dynamicRouteProps : undefined}
|
hideFilters={SIMPLE_SITE ? !dynamicRouteProps : undefined}
|
||||||
header={useDualList ? <span /> : repostedUri ? <span /> : undefined}
|
header={useDualList ? <span /> : repostedUri ? <span /> : undefined}
|
||||||
|
|
Loading…
Reference in a new issue