2019-06-11 20:10:58 +02:00
|
|
|
// @flow
|
Fix 'content=any' not producing Channels in result
## Issue
1378
> "Content Type: Any" uses `claim_type: [streams, reposts, channels]`, with `stream_types: ["video", "audio"]`, so channels aren't returned, and not any types of streams either. Probably shouldn't have `stream_type` filter there.
(This also happens in categories, but maybe wanted in there?)
## Root
Due to this line in `ClaimListDiscover`:
`defaultStreamType = SIMPLE_SITE ? [CS.FILE_VIDEO, CS.FILE_AUDIO] : undefined, // add param for DEFAULT_STREAM_TYPE`
Wanted to check if this fallback was meant for Categories only or any list, but the git history is not preserved because Odysee was a squashed single-commit back in the `SIMPLE_SITE` days.
## Change
Will assume it was meant for Category Page only and moved that line from the component and into the client-side.
This also means that clients of `ClaimListDiscover` without `streamTypes` and `defaultStreamTypes` defined will no longer have `stream_types: ['video', 'audio']` as the automatic fallback (they must define `defaultStreamTypes` themselves). I think this modal is clearer -- it doesn't make sense to have filters like "content=any" but overridden quietly to `video|audio`.
2022-04-25 05:32:38 +02:00
|
|
|
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
2019-06-17 22:32:38 +02:00
|
|
|
import type { Node } from 'react';
|
2020-08-21 17:49:13 +02:00
|
|
|
import * as CS from 'constants/claim_search';
|
|
|
|
import React from 'react';
|
2020-06-14 19:57:31 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2019-07-17 22:49:06 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { MATURE_TAGS } from 'constants/tags';
|
2022-02-24 11:06:38 +01:00
|
|
|
import { resolveLangForClaimSearch } from 'util/default-languages';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { createNormalizedClaimSearchKey } from 'util/claim';
|
|
|
|
import { splitBySeparator } from 'util/lbryURI';
|
2019-08-15 00:32:55 +02:00
|
|
|
import Button from 'component/button';
|
2019-07-17 22:49:06 +02:00
|
|
|
import moment from 'moment';
|
2019-06-19 07:05:43 +02:00
|
|
|
import ClaimList from 'component/claimList';
|
2019-06-27 08:18:45 +02:00
|
|
|
import ClaimPreview from 'component/claimPreview';
|
2020-08-26 23:16:45 +02:00
|
|
|
import ClaimPreviewTile from 'component/claimPreviewTile';
|
2019-11-13 19:11:51 +01:00
|
|
|
import I18nMessage from 'component/i18nMessage';
|
2022-02-25 09:48:45 +01:00
|
|
|
import LangFilterIndicator from 'component/langFilterIndicator';
|
2020-08-21 17:49:13 +02:00
|
|
|
import ClaimListHeader from 'component/claimListHeader';
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
import useFetchViewCount from 'effects/use-fetch-view-count';
|
2022-03-25 08:53:04 +01:00
|
|
|
import useResolvePins from 'effects/use-resolve-pins';
|
2020-09-08 22:41:05 +02:00
|
|
|
import { useIsLargeScreen } from 'effects/use-screensize';
|
2022-03-09 19:05:37 +01:00
|
|
|
import useGetUserMemberships from 'effects/use-get-user-memberships';
|
2019-06-11 20:10:58 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uris: Array<string>,
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
prefixUris?: Array<string>,
|
2022-03-25 08:53:04 +01:00
|
|
|
pins?: { urls?: Array<string>, claimIds?: Array<string>, onlyPinForOrder?: string },
|
2021-09-13 05:28:22 +02:00
|
|
|
name?: string,
|
2021-04-06 20:59:12 +02:00
|
|
|
type: string,
|
2021-09-13 05:28:22 +02:00
|
|
|
pageSize?: number,
|
|
|
|
|
2021-09-09 09:02:31 +02:00
|
|
|
fetchViewCount?: boolean,
|
2022-07-05 19:20:10 +02:00
|
|
|
hideRepostsOverride?: boolean, // undefined = use SETTINGS.HIDE_REPOSTS; true/false: use this.
|
2021-09-13 05:28:22 +02:00
|
|
|
hasNoSource?: boolean,
|
|
|
|
hasSource?: boolean,
|
|
|
|
hideAdvancedFilter?: boolean,
|
|
|
|
hideFilters?: boolean,
|
|
|
|
includeSupportAction?: boolean,
|
|
|
|
infiniteScroll?: Boolean,
|
|
|
|
isChannel?: boolean,
|
|
|
|
personalView: boolean,
|
|
|
|
showHeader: boolean,
|
|
|
|
showHiddenByUser?: boolean,
|
|
|
|
showNoSourceClaims?: boolean,
|
|
|
|
tileLayout: boolean,
|
2022-04-19 14:56:28 +02:00
|
|
|
searchLanguages?: Array<string>,
|
2022-04-19 13:42:33 +02:00
|
|
|
ignoreSearchInLanguage?: boolean, // Negate the redux setting where it doesn't make sense.
|
2021-09-13 05:28:22 +02:00
|
|
|
|
2021-09-13 17:23:53 +02:00
|
|
|
orderBy?: Array<string>, // Trending, New, Top
|
2020-02-10 20:43:24 +01:00
|
|
|
defaultOrderBy?: string,
|
2021-09-13 17:23:53 +02:00
|
|
|
sortBy?: Array<string>, // Newest First, Oldest First
|
2020-02-10 20:43:24 +01:00
|
|
|
freshness?: string,
|
|
|
|
defaultFreshness?: string,
|
2021-09-13 05:28:22 +02:00
|
|
|
|
|
|
|
tags: string, // these are just going to be string. pass a CSV if you want multi
|
|
|
|
defaultTags: string,
|
|
|
|
|
2021-03-26 00:52:28 +01:00
|
|
|
claimType?: string | Array<string>,
|
2020-02-28 22:52:42 +01:00
|
|
|
defaultClaimType?: Array<string>,
|
2021-09-13 05:28:22 +02:00
|
|
|
|
2020-02-10 20:43:24 +01:00
|
|
|
streamType?: string | Array<string>,
|
|
|
|
defaultStreamType?: string | Array<string>,
|
2021-09-13 05:28:22 +02:00
|
|
|
|
|
|
|
empty?: string,
|
2020-05-21 17:38:28 +02:00
|
|
|
feeAmount?: string,
|
2021-09-13 05:28:22 +02:00
|
|
|
releaseTime?: string,
|
|
|
|
repostedClaimId?: string,
|
2020-11-25 18:09:58 +01:00
|
|
|
scrollAnchor?: string,
|
2021-09-13 05:28:22 +02:00
|
|
|
maxPages?: number,
|
2021-07-17 20:55:18 +02:00
|
|
|
limitClaimsPerChannel?: number,
|
2021-09-13 05:28:22 +02:00
|
|
|
|
|
|
|
channelIds?: Array<string>,
|
2022-04-19 14:56:37 +02:00
|
|
|
excludedChannelIds?: Array<string>,
|
2021-09-13 05:28:22 +02:00
|
|
|
claimIds?: Array<string>,
|
|
|
|
subscribedChannels: Array<Subscription>,
|
|
|
|
|
|
|
|
header?: Node,
|
|
|
|
headerLabel?: string | Node,
|
|
|
|
hiddenNsfwMessage?: Node,
|
2022-04-18 13:04:42 +02:00
|
|
|
injectedItem?: ListInjectedItem,
|
2021-09-13 05:28:22 +02:00
|
|
|
meta?: Node,
|
2022-02-28 11:02:47 +01:00
|
|
|
subSection?: Node, // Additional section below [Header|Meta]
|
2021-09-13 05:28:22 +02:00
|
|
|
renderProperties?: (Claim) => Node,
|
|
|
|
|
|
|
|
history: { action: string, push: (string) => void, replace: (string) => void },
|
|
|
|
location: { search: string, pathname: string },
|
|
|
|
|
|
|
|
// --- select ---
|
|
|
|
followedTags?: Array<Tag>,
|
|
|
|
claimSearchByQuery: { [string]: Array<string> },
|
|
|
|
claimSearchByQueryLastPageReached: { [string]: boolean },
|
2021-09-09 09:02:31 +02:00
|
|
|
claimsByUri: { [string]: any },
|
2022-03-25 08:53:04 +01:00
|
|
|
claimsById: { [string]: any },
|
2021-09-13 05:28:22 +02:00
|
|
|
loading: boolean,
|
|
|
|
showNsfw: boolean,
|
|
|
|
hideReposts: boolean,
|
|
|
|
languageSetting: string,
|
|
|
|
mutedUris: Array<string>,
|
|
|
|
blockedUris: Array<string>,
|
|
|
|
searchInLanguage: boolean,
|
|
|
|
|
|
|
|
// --- perform ---
|
|
|
|
doClaimSearch: ({}) => void,
|
2021-09-09 09:02:31 +02:00
|
|
|
doFetchViewCount: (claimIdCsv: string) => void,
|
2022-03-09 19:05:37 +01:00
|
|
|
doFetchUserMemberships: (claimIdCsv: string) => void,
|
2022-03-25 08:53:04 +01:00
|
|
|
doResolveClaimIds: (Array<string>) => Promise<any>,
|
|
|
|
doResolveUris: (Array<string>, boolean) => Promise<any>,
|
2021-12-16 22:59:13 +01:00
|
|
|
|
|
|
|
hideLayoutButton?: boolean,
|
|
|
|
loadedCallback?: (number) => void,
|
|
|
|
maxClaimRender?: number,
|
|
|
|
useSkeletonScreen?: boolean,
|
|
|
|
excludeUris?: Array<string>,
|
2022-01-06 22:13:26 +01:00
|
|
|
|
|
|
|
swipeLayout: boolean,
|
2019-06-11 20:10:58 +02:00
|
|
|
};
|
|
|
|
|
2019-06-19 07:05:43 +02:00
|
|
|
function ClaimListDiscover(props: Props) {
|
2019-07-17 22:49:06 +02:00
|
|
|
const {
|
|
|
|
doClaimSearch,
|
|
|
|
claimSearchByQuery,
|
2021-04-06 20:59:12 +02:00
|
|
|
showHeader = true,
|
|
|
|
type,
|
2020-07-12 08:28:41 +02:00
|
|
|
claimSearchByQueryLastPageReached,
|
2019-07-17 22:49:06 +02:00
|
|
|
tags,
|
2020-03-12 02:43:52 +01:00
|
|
|
defaultTags,
|
2019-07-17 22:49:06 +02:00
|
|
|
loading,
|
|
|
|
meta,
|
2022-02-28 11:02:47 +01:00
|
|
|
subSection,
|
2020-01-02 17:30:27 +01:00
|
|
|
channelIds,
|
2022-04-19 14:56:37 +02:00
|
|
|
excludedChannelIds,
|
2019-07-17 22:49:06 +02:00
|
|
|
showNsfw,
|
2020-04-15 18:43:22 +02:00
|
|
|
hideReposts,
|
2021-09-09 09:02:31 +02:00
|
|
|
fetchViewCount,
|
2019-07-17 22:49:06 +02:00
|
|
|
history,
|
|
|
|
location,
|
2021-03-03 19:50:16 +01:00
|
|
|
mutedUris,
|
|
|
|
blockedUris,
|
2019-10-14 03:19:24 +02:00
|
|
|
hiddenNsfwMessage,
|
2020-02-11 20:04:51 +01:00
|
|
|
defaultOrderBy,
|
2021-09-13 17:23:53 +02:00
|
|
|
sortBy,
|
2020-02-10 20:43:24 +01:00
|
|
|
orderBy,
|
2020-01-02 21:36:03 +01:00
|
|
|
headerLabel,
|
2020-02-11 20:04:51 +01:00
|
|
|
header,
|
|
|
|
name,
|
2020-02-21 17:33:14 +01:00
|
|
|
claimType,
|
2020-02-10 20:43:24 +01:00
|
|
|
defaultClaimType,
|
2022-01-14 04:03:04 +01:00
|
|
|
streamType,
|
Fix 'content=any' not producing Channels in result
## Issue
1378
> "Content Type: Any" uses `claim_type: [streams, reposts, channels]`, with `stream_types: ["video", "audio"]`, so channels aren't returned, and not any types of streams either. Probably shouldn't have `stream_type` filter there.
(This also happens in categories, but maybe wanted in there?)
## Root
Due to this line in `ClaimListDiscover`:
`defaultStreamType = SIMPLE_SITE ? [CS.FILE_VIDEO, CS.FILE_AUDIO] : undefined, // add param for DEFAULT_STREAM_TYPE`
Wanted to check if this fallback was meant for Categories only or any list, but the git history is not preserved because Odysee was a squashed single-commit back in the `SIMPLE_SITE` days.
## Change
Will assume it was meant for Category Page only and moved that line from the component and into the client-side.
This also means that clients of `ClaimListDiscover` without `streamTypes` and `defaultStreamTypes` defined will no longer have `stream_types: ['video', 'audio']` as the automatic fallback (they must define `defaultStreamTypes` themselves). I think this modal is clearer -- it doesn't make sense to have filters like "content=any" but overridden quietly to `video|audio`.
2022-04-25 05:32:38 +02:00
|
|
|
defaultStreamType,
|
2020-02-10 20:43:24 +01:00
|
|
|
freshness,
|
2020-02-27 23:15:17 +01:00
|
|
|
defaultFreshness = CS.FRESH_WEEK,
|
2020-02-11 20:04:51 +01:00
|
|
|
renderProperties,
|
2020-02-12 19:59:48 +01:00
|
|
|
includeSupportAction,
|
2020-03-19 17:54:37 +01:00
|
|
|
repostedClaimId,
|
2020-09-30 20:46:17 +02:00
|
|
|
hideAdvancedFilter,
|
2020-04-22 14:07:09 +02:00
|
|
|
infiniteScroll = true,
|
2020-03-12 02:43:52 +01:00
|
|
|
followedTags,
|
2020-03-26 22:47:07 +01:00
|
|
|
injectedItem,
|
2020-05-21 17:38:28 +02:00
|
|
|
feeAmount,
|
2020-06-18 17:10:46 +02:00
|
|
|
uris,
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
prefixUris,
|
2021-12-01 16:18:57 +01:00
|
|
|
pins,
|
2020-08-21 17:49:13 +02:00
|
|
|
tileLayout,
|
2020-10-02 19:48:28 +02:00
|
|
|
hideFilters = false,
|
2020-09-30 20:46:17 +02:00
|
|
|
claimIds,
|
|
|
|
maxPages,
|
2022-07-05 19:20:10 +02:00
|
|
|
hideRepostsOverride,
|
2020-10-15 19:56:55 +02:00
|
|
|
languageSetting,
|
2022-04-19 14:56:28 +02:00
|
|
|
searchLanguages,
|
2020-10-15 19:56:55 +02:00
|
|
|
searchInLanguage,
|
2022-02-23 15:43:42 +01:00
|
|
|
ignoreSearchInLanguage,
|
2021-07-17 20:55:18 +02:00
|
|
|
limitClaimsPerChannel,
|
|
|
|
releaseTime,
|
2020-11-25 18:09:58 +01:00
|
|
|
scrollAnchor,
|
2021-03-03 19:50:16 +01:00
|
|
|
showHiddenByUser = false,
|
2021-04-29 11:33:24 +02:00
|
|
|
hasSource,
|
2021-08-27 16:57:54 +02:00
|
|
|
hasNoSource,
|
2021-05-15 07:53:56 +02:00
|
|
|
isChannel = false,
|
2021-07-07 20:21:11 +02:00
|
|
|
showNoSourceClaims,
|
2021-06-10 23:01:32 +02:00
|
|
|
empty,
|
2021-09-09 09:02:31 +02:00
|
|
|
claimsByUri,
|
2022-03-25 08:53:04 +01:00
|
|
|
claimsById,
|
2021-09-09 09:02:31 +02:00
|
|
|
doFetchViewCount,
|
2021-12-16 22:59:13 +01:00
|
|
|
hideLayoutButton = false,
|
|
|
|
loadedCallback,
|
|
|
|
maxClaimRender,
|
|
|
|
useSkeletonScreen = true,
|
|
|
|
excludeUris = [],
|
2022-03-09 19:05:37 +01:00
|
|
|
doFetchUserMemberships,
|
2022-01-06 22:13:26 +01:00
|
|
|
swipeLayout = false,
|
2022-03-25 08:53:04 +01:00
|
|
|
doResolveUris,
|
|
|
|
doResolveClaimIds,
|
2019-07-17 22:49:06 +02:00
|
|
|
} = props;
|
2022-03-25 08:53:04 +01:00
|
|
|
|
|
|
|
const resolvedPinUris = useResolvePins({ pins, claimsById, doResolveClaimIds, doResolveUris });
|
2019-07-17 22:49:06 +02:00
|
|
|
const didNavigateForward = history.action === 'PUSH';
|
2019-09-11 20:29:20 +02:00
|
|
|
const { search } = location;
|
2022-03-21 14:50:51 +01:00
|
|
|
const prevUris = React.useRef();
|
2020-08-21 17:49:13 +02:00
|
|
|
const [page, setPage] = React.useState(1);
|
|
|
|
const [forceRefresh, setForceRefresh] = React.useState();
|
2020-09-08 22:41:05 +02:00
|
|
|
const isLargeScreen = useIsLargeScreen();
|
2020-07-11 16:19:30 +02:00
|
|
|
const [orderParamEntry, setOrderParamEntry] = usePersistedState(`entry-${location.pathname}`, CS.ORDER_BY_TRENDING);
|
2020-06-14 19:57:31 +02:00
|
|
|
const [orderParamUser, setOrderParamUser] = usePersistedState(`orderUser-${location.pathname}`, CS.ORDER_BY_TRENDING);
|
2021-05-15 07:52:24 +02:00
|
|
|
const followed = (followedTags && followedTags.map((t) => t.name)) || [];
|
2019-07-17 22:49:06 +02:00
|
|
|
const urlParams = new URLSearchParams(search);
|
2020-03-12 02:43:52 +01:00
|
|
|
const tagsParam = // can be 'x,y,z' or 'x' or ['x','y'] or CS.CONSTANT
|
|
|
|
(tags && getParamFromTags(tags)) ||
|
|
|
|
(urlParams.get(CS.TAGS_KEY) !== null && urlParams.get(CS.TAGS_KEY)) ||
|
|
|
|
(defaultTags && getParamFromTags(defaultTags));
|
2020-02-27 23:15:17 +01:00
|
|
|
const freshnessParam = freshness || urlParams.get(CS.FRESH_KEY) || defaultFreshness;
|
2021-09-13 17:23:53 +02:00
|
|
|
const sortByParam = sortBy || urlParams.get(CS.SORT_BY_KEY) || CS.SORT_BY.NEWEST.key;
|
2021-07-15 22:22:44 +02:00
|
|
|
const mutedAndBlockedChannelIds = Array.from(
|
|
|
|
new Set(mutedUris.concat(blockedUris).map((uri) => splitBySeparator(uri)[1]))
|
|
|
|
);
|
2022-05-23 11:32:57 +02:00
|
|
|
const [hiddenBuffer, setHiddenBuffer] = React.useState([]);
|
2022-07-05 19:20:10 +02:00
|
|
|
const hideRepostsEffective = resolveHideReposts(hideReposts, hideRepostsOverride);
|
2020-10-15 19:56:55 +02:00
|
|
|
|
|
|
|
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
|
2022-04-22 08:32:56 +02:00
|
|
|
const searchInSelectedLang = searchInLanguage && !ignoreSearchInLanguage;
|
|
|
|
const languageParams = resolveLangForClaimSearch(languageSetting, searchInSelectedLang, searchLanguages, langParam);
|
2020-10-15 19:56:55 +02:00
|
|
|
|
Resolve claim and stream types when there is a filter (#696)
* Resolve claim and stream types when there is a filter
## Symptom
Channel Page 'Content Type' filter not working
## Issue
The Advanced Filter work by placing a `?content=` URL param. The list component then parses it and makes the `claim_search` params accordingly. But:
1. There is a mix up in how the list component treats `?content=`.
- The original code seems to treat this as a way to define the type externally but only for a list without `claimType` defined via code. In other words, if `claimType="something"`, `?content=` is ignored.
- On the other hand, the Advanced Filter relies on `?content=` being used.
2. `?content=` is then split between `claimType` and `streamType`. The current code does not check if the split makes sense, e.g. if `?content=channel` and `streamType=['video']`, these 2 are incompatible and produces no results.
## Change
1. I'm not really sure what's the original intention, but let's just make `?content=` as an override/filter.
2. `?content=` should probably be limited to always be a subset of `claimType` and `streamType`. But this seems complicated to do, so for now let's just make always override/filter everything. For that, we need to make sure the filtered `claimType` -- `streamType` combo makes sense.
* Fix 'Channel' filter not working in Wild West
## Cause
The Wild West list defines `release_time` to be 1 week ago. As long as this parameter exists, a channel `claim_search` produces no results (I thought channels have creation dates?). That is why an unfiltered Wild West never showed Channel Tiles.
## Change
The existing `release_time` handling does seem to hint that we should not set the parameter when searching for Channels. Expanded that to consider the final (filtered) claim type, not just the original.
2022-01-14 17:06:13 +01:00
|
|
|
let claimTypeParam = claimType || defaultClaimType || null;
|
|
|
|
let streamTypeParam = streamType || defaultStreamType || null;
|
|
|
|
|
2020-02-10 20:43:24 +01:00
|
|
|
const contentTypeParam = urlParams.get(CS.CONTENT_KEY);
|
Resolve claim and stream types when there is a filter (#696)
* Resolve claim and stream types when there is a filter
## Symptom
Channel Page 'Content Type' filter not working
## Issue
The Advanced Filter work by placing a `?content=` URL param. The list component then parses it and makes the `claim_search` params accordingly. But:
1. There is a mix up in how the list component treats `?content=`.
- The original code seems to treat this as a way to define the type externally but only for a list without `claimType` defined via code. In other words, if `claimType="something"`, `?content=` is ignored.
- On the other hand, the Advanced Filter relies on `?content=` being used.
2. `?content=` is then split between `claimType` and `streamType`. The current code does not check if the split makes sense, e.g. if `?content=channel` and `streamType=['video']`, these 2 are incompatible and produces no results.
## Change
1. I'm not really sure what's the original intention, but let's just make `?content=` as an override/filter.
2. `?content=` should probably be limited to always be a subset of `claimType` and `streamType`. But this seems complicated to do, so for now let's just make always override/filter everything. For that, we need to make sure the filtered `claimType` -- `streamType` combo makes sense.
* Fix 'Channel' filter not working in Wild West
## Cause
The Wild West list defines `release_time` to be 1 week ago. As long as this parameter exists, a channel `claim_search` produces no results (I thought channels have creation dates?). That is why an unfiltered Wild West never showed Channel Tiles.
## Change
The existing `release_time` handling does seem to hint that we should not set the parameter when searching for Channels. Expanded that to consider the final (filtered) claim type, not just the original.
2022-01-14 17:06:13 +01:00
|
|
|
if (contentTypeParam) {
|
|
|
|
switch (contentTypeParam) {
|
|
|
|
case CS.CLAIM_COLLECTION:
|
2022-01-17 18:06:59 +01:00
|
|
|
claimTypeParam = contentTypeParam;
|
|
|
|
streamTypeParam = undefined;
|
|
|
|
break;
|
Resolve claim and stream types when there is a filter (#696)
* Resolve claim and stream types when there is a filter
## Symptom
Channel Page 'Content Type' filter not working
## Issue
The Advanced Filter work by placing a `?content=` URL param. The list component then parses it and makes the `claim_search` params accordingly. But:
1. There is a mix up in how the list component treats `?content=`.
- The original code seems to treat this as a way to define the type externally but only for a list without `claimType` defined via code. In other words, if `claimType="something"`, `?content=` is ignored.
- On the other hand, the Advanced Filter relies on `?content=` being used.
2. `?content=` is then split between `claimType` and `streamType`. The current code does not check if the split makes sense, e.g. if `?content=channel` and `streamType=['video']`, these 2 are incompatible and produces no results.
## Change
1. I'm not really sure what's the original intention, but let's just make `?content=` as an override/filter.
2. `?content=` should probably be limited to always be a subset of `claimType` and `streamType`. But this seems complicated to do, so for now let's just make always override/filter everything. For that, we need to make sure the filtered `claimType` -- `streamType` combo makes sense.
* Fix 'Channel' filter not working in Wild West
## Cause
The Wild West list defines `release_time` to be 1 week ago. As long as this parameter exists, a channel `claim_search` produces no results (I thought channels have creation dates?). That is why an unfiltered Wild West never showed Channel Tiles.
## Change
The existing `release_time` handling does seem to hint that we should not set the parameter when searching for Channels. Expanded that to consider the final (filtered) claim type, not just the original.
2022-01-14 17:06:13 +01:00
|
|
|
case CS.CLAIM_REPOST:
|
|
|
|
claimTypeParam = contentTypeParam;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CS.CLAIM_CHANNEL:
|
|
|
|
claimTypeParam = CS.CLAIM_CHANNEL;
|
|
|
|
streamTypeParam = undefined;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CS.FILE_VIDEO:
|
|
|
|
case CS.FILE_AUDIO:
|
|
|
|
case CS.FILE_IMAGE:
|
|
|
|
case CS.FILE_MODEL:
|
|
|
|
case CS.FILE_BINARY:
|
|
|
|
case CS.FILE_DOCUMENT:
|
|
|
|
streamTypeParam = contentTypeParam;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CS.CONTENT_ALL:
|
|
|
|
claimTypeParam = undefined;
|
|
|
|
streamTypeParam = undefined;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-02-25 09:48:45 +01:00
|
|
|
console.log('Invalid or unhandled CONTENT_KEY:', contentTypeParam); // eslint-disable-line no-console
|
Resolve claim and stream types when there is a filter (#696)
* Resolve claim and stream types when there is a filter
## Symptom
Channel Page 'Content Type' filter not working
## Issue
The Advanced Filter work by placing a `?content=` URL param. The list component then parses it and makes the `claim_search` params accordingly. But:
1. There is a mix up in how the list component treats `?content=`.
- The original code seems to treat this as a way to define the type externally but only for a list without `claimType` defined via code. In other words, if `claimType="something"`, `?content=` is ignored.
- On the other hand, the Advanced Filter relies on `?content=` being used.
2. `?content=` is then split between `claimType` and `streamType`. The current code does not check if the split makes sense, e.g. if `?content=channel` and `streamType=['video']`, these 2 are incompatible and produces no results.
## Change
1. I'm not really sure what's the original intention, but let's just make `?content=` as an override/filter.
2. `?content=` should probably be limited to always be a subset of `claimType` and `streamType`. But this seems complicated to do, so for now let's just make always override/filter everything. For that, we need to make sure the filtered `claimType` -- `streamType` combo makes sense.
* Fix 'Channel' filter not working in Wild West
## Cause
The Wild West list defines `release_time` to be 1 week ago. As long as this parameter exists, a channel `claim_search` produces no results (I thought channels have creation dates?). That is why an unfiltered Wild West never showed Channel Tiles.
## Change
The existing `release_time` handling does seem to hint that we should not set the parameter when searching for Channels. Expanded that to consider the final (filtered) claim type, not just the original.
2022-01-14 17:06:13 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-10 20:43:24 +01:00
|
|
|
const durationParam = urlParams.get(CS.DURATION_KEY) || null;
|
2020-05-21 17:38:28 +02:00
|
|
|
const channelIdsInUrl = urlParams.get(CS.CHANNEL_IDS_KEY);
|
|
|
|
const channelIdsParam = channelIdsInUrl ? channelIdsInUrl.split(',') : channelIds;
|
2022-04-19 14:56:37 +02:00
|
|
|
const excludedIdsParam = excludedChannelIds;
|
2021-07-21 16:51:26 +02:00
|
|
|
const feeAmountParam = urlParams.get('fee_amount') || feeAmount;
|
2022-04-07 19:54:41 +02:00
|
|
|
const originalPageSize = 12;
|
2022-05-23 11:32:57 +02:00
|
|
|
const dynamicPageSize = isLargeScreen ? Math.ceil((originalPageSize / 2) * 6) : Math.ceil((originalPageSize / 2) * 4);
|
2020-12-01 18:56:59 +01:00
|
|
|
const historyAction = history.action;
|
|
|
|
|
2021-07-17 20:55:18 +02:00
|
|
|
let orderParam = orderBy || urlParams.get(CS.ORDER_BY_KEY) || defaultOrderBy || orderParamEntry;
|
2020-11-20 17:46:26 +01:00
|
|
|
|
2020-06-14 19:57:31 +02:00
|
|
|
if (!orderParam) {
|
2020-12-01 18:56:59 +01:00
|
|
|
if (historyAction === 'POP') {
|
2020-06-14 19:57:31 +02:00
|
|
|
// Reaching here means user have popped back to the page's entry point (e.g. '/$/tags' without any '?order=').
|
|
|
|
orderParam = orderParamEntry;
|
|
|
|
} else {
|
|
|
|
// This is the direct entry into the page, so we load the user's previous value.
|
|
|
|
orderParam = orderParamUser;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-21 17:49:13 +02:00
|
|
|
React.useEffect(() => {
|
2020-06-14 19:57:31 +02:00
|
|
|
setOrderParamUser(orderParam);
|
2020-12-01 18:56:59 +01:00
|
|
|
}, [orderParam, setOrderParamUser]);
|
2020-06-14 19:57:31 +02:00
|
|
|
|
2020-08-21 17:49:13 +02:00
|
|
|
React.useEffect(() => {
|
2020-06-14 19:57:31 +02:00
|
|
|
// One-time update to stash the finalized 'orderParam' at entry.
|
2020-12-01 18:56:59 +01:00
|
|
|
if (historyAction !== 'POP') {
|
2020-07-11 16:19:30 +02:00
|
|
|
setOrderParamEntry(orderParam);
|
|
|
|
}
|
2020-12-01 18:56:59 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [historyAction, setOrderParamEntry]);
|
2020-06-14 19:57:31 +02:00
|
|
|
|
2020-03-19 17:54:37 +01:00
|
|
|
let options: {
|
2019-07-17 22:49:06 +02:00
|
|
|
page_size: number,
|
|
|
|
page: number,
|
|
|
|
no_totals: boolean,
|
2020-03-12 02:43:52 +01:00
|
|
|
any_tags?: Array<string>,
|
2020-10-15 19:56:55 +02:00
|
|
|
any_languages?: Array<string>,
|
2020-02-10 20:43:24 +01:00
|
|
|
not_tags: Array<string>,
|
2020-10-02 19:48:28 +02:00
|
|
|
channel_ids?: Array<string>,
|
2020-09-30 20:46:17 +02:00
|
|
|
claim_ids?: Array<string>,
|
2021-05-15 07:53:56 +02:00
|
|
|
not_channel_ids?: Array<string>,
|
2019-07-17 22:49:06 +02:00
|
|
|
order_by: Array<string>,
|
|
|
|
release_time?: string,
|
2021-03-26 00:52:28 +01:00
|
|
|
claim_type?: string | Array<string>,
|
2020-02-11 20:04:51 +01:00
|
|
|
name?: string,
|
2020-02-10 20:43:24 +01:00
|
|
|
duration?: string,
|
2020-03-24 17:31:23 +01:00
|
|
|
reposted_claim_id?: string,
|
2020-02-10 20:43:24 +01:00
|
|
|
stream_types?: any,
|
2020-05-21 17:38:28 +02:00
|
|
|
fee_amount?: string,
|
2021-03-18 16:41:21 +01:00
|
|
|
has_source?: boolean,
|
|
|
|
has_no_source?: boolean,
|
2021-07-17 20:55:18 +02:00
|
|
|
limit_claims_per_channel?: number,
|
2021-11-24 17:11:25 +01:00
|
|
|
remove_duplicates?: boolean,
|
2019-07-17 22:49:06 +02:00
|
|
|
} = {
|
2020-09-08 22:41:05 +02:00
|
|
|
page_size: dynamicPageSize,
|
2019-07-17 22:49:06 +02:00
|
|
|
page,
|
2020-02-11 20:04:51 +01:00
|
|
|
name,
|
2021-08-27 16:57:54 +02:00
|
|
|
claim_type: claimType || ['stream', 'repost', 'channel'],
|
2019-07-17 22:49:06 +02:00
|
|
|
// 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,
|
2021-05-15 07:53:56 +02:00
|
|
|
not_channel_ids: isChannel ? undefined : mutedAndBlockedChannelIds,
|
2019-07-17 22:49:06 +02:00
|
|
|
not_tags: !showNsfw ? MATURE_TAGS : [],
|
2021-09-13 17:23:53 +02:00
|
|
|
order_by: resolveOrderByOption(orderParam, sortByParam),
|
2021-11-24 17:11:25 +01:00
|
|
|
remove_duplicates: isChannel ? undefined : true,
|
2019-07-17 22:49:06 +02:00
|
|
|
};
|
2020-03-19 17:54:37 +01:00
|
|
|
|
2021-08-27 16:57:54 +02:00
|
|
|
if (ENABLE_NO_SOURCE_CLAIMS && hasNoSource) {
|
|
|
|
options.has_no_source = true;
|
|
|
|
} else if (hasSource || (!ENABLE_NO_SOURCE_CLAIMS && (!claimType || claimType === 'stream'))) {
|
2021-03-17 18:49:55 +01:00
|
|
|
options.has_source = true;
|
2021-03-18 16:41:21 +01:00
|
|
|
}
|
|
|
|
|
2021-07-17 20:55:18 +02:00
|
|
|
if (limitClaimsPerChannel) {
|
|
|
|
options.limit_claims_per_channel = limitClaimsPerChannel;
|
|
|
|
}
|
|
|
|
|
2020-10-22 18:59:41 +02:00
|
|
|
if (feeAmountParam && claimType !== CS.CLAIM_CHANNEL) {
|
|
|
|
options.fee_amount = feeAmountParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (claimIds) {
|
|
|
|
options.claim_ids = claimIds;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (channelIdsParam) {
|
|
|
|
options.channel_ids = channelIdsParam;
|
|
|
|
}
|
|
|
|
|
2022-04-19 14:56:37 +02:00
|
|
|
if (excludedIdsParam) {
|
|
|
|
options.not_channel_ids = (options.not_channel_ids || []).concat(excludedIdsParam);
|
|
|
|
}
|
|
|
|
|
2020-10-22 18:59:41 +02:00
|
|
|
if (tagsParam) {
|
|
|
|
if (tagsParam !== CS.TAGS_ALL && tagsParam !== '') {
|
|
|
|
if (tagsParam === CS.TAGS_FOLLOWED) {
|
|
|
|
options.any_tags = followed;
|
|
|
|
} else if (Array.isArray(tagsParam)) {
|
|
|
|
options.any_tags = tagsParam;
|
|
|
|
} else {
|
|
|
|
options.any_tags = tagsParam.split(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-19 17:54:37 +01:00
|
|
|
if (repostedClaimId) {
|
|
|
|
// SDK chokes on reposted_claim_id of null or false, needs to not be present if no value
|
|
|
|
options.reposted_claim_id = repostedClaimId;
|
|
|
|
}
|
2021-07-17 20:55:18 +02:00
|
|
|
// IF release time, set it, else set fallback release times using the hack below.
|
Resolve claim and stream types when there is a filter (#696)
* Resolve claim and stream types when there is a filter
## Symptom
Channel Page 'Content Type' filter not working
## Issue
The Advanced Filter work by placing a `?content=` URL param. The list component then parses it and makes the `claim_search` params accordingly. But:
1. There is a mix up in how the list component treats `?content=`.
- The original code seems to treat this as a way to define the type externally but only for a list without `claimType` defined via code. In other words, if `claimType="something"`, `?content=` is ignored.
- On the other hand, the Advanced Filter relies on `?content=` being used.
2. `?content=` is then split between `claimType` and `streamType`. The current code does not check if the split makes sense, e.g. if `?content=channel` and `streamType=['video']`, these 2 are incompatible and produces no results.
## Change
1. I'm not really sure what's the original intention, but let's just make `?content=` as an override/filter.
2. `?content=` should probably be limited to always be a subset of `claimType` and `streamType`. But this seems complicated to do, so for now let's just make always override/filter everything. For that, we need to make sure the filtered `claimType` -- `streamType` combo makes sense.
* Fix 'Channel' filter not working in Wild West
## Cause
The Wild West list defines `release_time` to be 1 week ago. As long as this parameter exists, a channel `claim_search` produces no results (I thought channels have creation dates?). That is why an unfiltered Wild West never showed Channel Tiles.
## Change
The existing `release_time` handling does seem to hint that we should not set the parameter when searching for Channels. Expanded that to consider the final (filtered) claim type, not just the original.
2022-01-14 17:06:13 +01:00
|
|
|
if (releaseTime && claimTypeParam !== CS.CLAIM_CHANNEL) {
|
2021-07-17 20:55:18 +02:00
|
|
|
options.release_time = releaseTime;
|
Resolve claim and stream types when there is a filter (#696)
* Resolve claim and stream types when there is a filter
## Symptom
Channel Page 'Content Type' filter not working
## Issue
The Advanced Filter work by placing a `?content=` URL param. The list component then parses it and makes the `claim_search` params accordingly. But:
1. There is a mix up in how the list component treats `?content=`.
- The original code seems to treat this as a way to define the type externally but only for a list without `claimType` defined via code. In other words, if `claimType="something"`, `?content=` is ignored.
- On the other hand, the Advanced Filter relies on `?content=` being used.
2. `?content=` is then split between `claimType` and `streamType`. The current code does not check if the split makes sense, e.g. if `?content=channel` and `streamType=['video']`, these 2 are incompatible and produces no results.
## Change
1. I'm not really sure what's the original intention, but let's just make `?content=` as an override/filter.
2. `?content=` should probably be limited to always be a subset of `claimType` and `streamType`. But this seems complicated to do, so for now let's just make always override/filter everything. For that, we need to make sure the filtered `claimType` -- `streamType` combo makes sense.
* Fix 'Channel' filter not working in Wild West
## Cause
The Wild West list defines `release_time` to be 1 week ago. As long as this parameter exists, a channel `claim_search` produces no results (I thought channels have creation dates?). That is why an unfiltered Wild West never showed Channel Tiles.
## Change
The existing `release_time` handling does seem to hint that we should not set the parameter when searching for Channels. Expanded that to consider the final (filtered) claim type, not just the original.
2022-01-14 17:06:13 +01:00
|
|
|
} else if (claimTypeParam !== CS.CLAIM_CHANNEL) {
|
2020-10-02 19:48:28 +02:00
|
|
|
if (orderParam === CS.ORDER_BY_TOP && freshnessParam !== CS.FRESH_ALL) {
|
2021-05-15 07:52:24 +02:00
|
|
|
options.release_time = `>${Math.floor(moment().subtract(1, freshnessParam).startOf('hour').unix())}`;
|
2020-10-02 19:48:28 +02:00
|
|
|
} else if (orderParam === CS.ORDER_BY_NEW || orderParam === CS.ORDER_BY_TRENDING) {
|
|
|
|
// Warning - hack below
|
|
|
|
// If users are following more than 10 channels or tags, limit results to stuff less than a year old
|
|
|
|
// For more than 20, drop it down to 6 months
|
|
|
|
// This helps with timeout issues for users that are following a ton of stuff
|
|
|
|
// https://github.com/lbryio/lbry-sdk/issues/2420
|
|
|
|
if (
|
|
|
|
(options.channel_ids && options.channel_ids.length > 20) ||
|
|
|
|
(options.any_tags && options.any_tags.length > 20)
|
|
|
|
) {
|
2021-05-15 07:52:24 +02:00
|
|
|
options.release_time = `>${Math.floor(moment().subtract(3, CS.FRESH_MONTH).startOf('week').unix())}`;
|
2020-10-02 19:48:28 +02:00
|
|
|
} else if (
|
|
|
|
(options.channel_ids && options.channel_ids.length > 10) ||
|
|
|
|
(options.any_tags && options.any_tags.length > 10)
|
|
|
|
) {
|
2021-05-15 07:52:24 +02:00
|
|
|
options.release_time = `>${Math.floor(moment().subtract(1, CS.FRESH_YEAR).startOf('week').unix())}`;
|
2020-11-19 19:27:16 +01:00
|
|
|
} else {
|
|
|
|
// Hack for at least the New page until https://github.com/lbryio/lbry-sdk/issues/2591 is fixed
|
2021-05-15 07:52:24 +02:00
|
|
|
options.release_time = `<${Math.floor(moment().startOf('minute').unix())}`;
|
2020-10-02 19:48:28 +02:00
|
|
|
}
|
2020-01-24 21:38:33 +01:00
|
|
|
}
|
2019-07-17 22:49:06 +02:00
|
|
|
}
|
2020-01-02 17:30:27 +01:00
|
|
|
|
2020-02-10 20:43:24 +01:00
|
|
|
if (durationParam) {
|
|
|
|
if (durationParam === CS.DURATION_SHORT) {
|
2020-11-13 21:25:18 +01:00
|
|
|
options.duration = '<=240';
|
2020-02-10 20:43:24 +01:00
|
|
|
} else if (durationParam === CS.DURATION_LONG) {
|
2020-11-13 21:52:28 +01:00
|
|
|
options.duration = '>=1200';
|
2020-02-10 20:43:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 20:46:17 +02:00
|
|
|
if (streamTypeParam && streamTypeParam !== CS.CONTENT_ALL && claimType !== CS.CLAIM_CHANNEL) {
|
2021-08-03 20:34:48 +02:00
|
|
|
options.stream_types = typeof streamTypeParam === 'string' ? [streamTypeParam] : streamTypeParam;
|
2020-02-10 20:43:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (claimTypeParam) {
|
|
|
|
if (claimTypeParam !== CS.CONTENT_ALL) {
|
2020-02-28 22:52:42 +01:00
|
|
|
if (Array.isArray(claimTypeParam)) {
|
|
|
|
options.claim_type = claimTypeParam;
|
|
|
|
} else {
|
|
|
|
options.claim_type = [claimTypeParam];
|
|
|
|
}
|
2020-02-10 20:43:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 00:17:09 +01:00
|
|
|
if (languageParams) {
|
|
|
|
if (languageParams !== CS.LANGUAGES_ALL) {
|
|
|
|
options.any_languages = languageParams.split(',');
|
2020-10-15 19:56:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tagsParam) {
|
|
|
|
if (tagsParam !== CS.TAGS_ALL && tagsParam !== '') {
|
|
|
|
if (tagsParam === CS.TAGS_FOLLOWED) {
|
|
|
|
options.any_tags = followed;
|
|
|
|
} else if (Array.isArray(tagsParam)) {
|
|
|
|
options.any_tags = tagsParam;
|
|
|
|
} else {
|
|
|
|
options.any_tags = tagsParam.split(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-05 19:20:10 +02:00
|
|
|
if (hideRepostsEffective && !options.reposted_claim_id) {
|
2020-04-15 18:43:22 +02:00
|
|
|
if (Array.isArray(options.claim_type)) {
|
|
|
|
if (options.claim_type.length > 1) {
|
2021-05-15 07:52:24 +02:00
|
|
|
options.claim_type = options.claim_type.filter((claimType) => claimType !== 'repost');
|
2020-04-15 18:43:22 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
options.claim_type = ['stream', 'channel'];
|
|
|
|
}
|
|
|
|
}
|
2020-02-21 17:33:14 +01:00
|
|
|
|
2021-05-15 07:52:24 +02:00
|
|
|
const hasMatureTags = tagsParam && tagsParam.split(',').some((t) => MATURE_TAGS.includes(t));
|
2021-07-21 09:55:14 +02:00
|
|
|
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
const searchKey = createNormalizedClaimSearchKey(options);
|
|
|
|
const claimSearchResult = claimSearchByQuery[searchKey];
|
|
|
|
const claimSearchResultLastPageReached = claimSearchByQueryLastPageReached[searchKey];
|
2022-03-21 14:50:51 +01:00
|
|
|
const isUnfetchedClaimSearch = claimSearchResult === undefined;
|
2020-03-31 18:07:57 +02:00
|
|
|
|
2021-07-19 19:20:25 +02:00
|
|
|
// uncomment to fix an item on a page
|
|
|
|
// const fixUri = 'lbry://@corbettreport#0/lbryodysee#5';
|
|
|
|
// if (
|
|
|
|
// orderParam === CS.ORDER_BY_NEW &&
|
|
|
|
// claimSearchResult &&
|
|
|
|
// claimSearchResult.length > 2 &&
|
|
|
|
// window.location.pathname === '/$/rabbithole'
|
|
|
|
// ) {
|
|
|
|
// if (claimSearchResult.indexOf(fixUri) !== -1) {
|
|
|
|
// claimSearchResult.splice(claimSearchResult.indexOf(fixUri), 1);
|
|
|
|
// } else {
|
|
|
|
// claimSearchResult.pop();
|
|
|
|
// }
|
|
|
|
// claimSearchResult.splice(2, 0, fixUri);
|
|
|
|
// }
|
|
|
|
|
2020-08-21 17:49:13 +02:00
|
|
|
const [prevOptions, setPrevOptions] = React.useState(null);
|
2020-06-18 11:18:25 +02:00
|
|
|
|
|
|
|
if (!isJustScrollingToNewPage(prevOptions, options)) {
|
2020-06-23 15:08:06 +02:00
|
|
|
// --- New search, or search options changed.
|
2020-06-18 11:18:25 +02:00
|
|
|
setPrevOptions(options);
|
|
|
|
|
|
|
|
if (didNavigateForward) {
|
2020-11-25 18:17:19 +01:00
|
|
|
// --- Reset the page.
|
2020-06-18 11:18:25 +02:00
|
|
|
options.page = 1;
|
|
|
|
setPage(options.page);
|
2020-06-23 15:08:06 +02:00
|
|
|
} else if (claimSearchResult) {
|
2020-06-18 11:18:25 +02:00
|
|
|
// --- Update 'page' based on retrieved 'claimSearchResult'.
|
2020-09-08 22:41:05 +02:00
|
|
|
options.page = Math.ceil(claimSearchResult.length / dynamicPageSize);
|
2020-06-18 11:18:25 +02:00
|
|
|
if (options.page !== page) {
|
|
|
|
setPage(options.page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 10:05:51 +02:00
|
|
|
const shouldPerformSearch =
|
2022-02-25 05:48:00 +01:00
|
|
|
!uris &&
|
|
|
|
(claimSearchResult === undefined ||
|
|
|
|
didNavigateForward ||
|
|
|
|
(!loading &&
|
|
|
|
!claimSearchResultLastPageReached &&
|
|
|
|
claimSearchResult &&
|
|
|
|
claimSearchResult.length &&
|
|
|
|
claimSearchResult.length < dynamicPageSize * options.page &&
|
|
|
|
claimSearchResult.length % dynamicPageSize === 0));
|
2020-03-31 18:07:57 +02:00
|
|
|
|
2019-07-31 21:07:26 +02:00
|
|
|
// Don't use the query from createNormalizedClaimSearchKey for the effect since that doesn't include page & release_time
|
2019-07-17 22:49:06 +02:00
|
|
|
const optionsStringForEffect = JSON.stringify(options);
|
2019-07-03 06:43:32 +02:00
|
|
|
|
2020-03-31 18:07:57 +02:00
|
|
|
const timedOutMessage = (
|
2019-11-13 19:11:51 +01:00
|
|
|
<div>
|
|
|
|
<p>
|
|
|
|
<I18nMessage
|
|
|
|
tokens={{
|
|
|
|
again: (
|
|
|
|
<Button
|
|
|
|
button="link"
|
2020-02-10 20:43:24 +01:00
|
|
|
label={__('try again in a few seconds.')}
|
2019-11-13 19:11:51 +01:00
|
|
|
onClick={() => setForceRefresh(Date.now())}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
}}
|
|
|
|
>
|
2020-03-31 18:07:57 +02:00
|
|
|
Sorry, your request timed out. Modify your options or %again%
|
2019-11-13 19:11:51 +01:00
|
|
|
</I18nMessage>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<I18nMessage
|
|
|
|
tokens={{
|
2021-10-17 10:36:14 +02:00
|
|
|
contact_support: (
|
|
|
|
<Button button="link" label={__('contact support')} href="https://odysee.com/@OdyseeHelp:b?view=about" />
|
|
|
|
),
|
2019-11-13 19:11:51 +01:00
|
|
|
}}
|
|
|
|
>
|
2019-12-05 19:38:11 +01:00
|
|
|
If you continue to have issues, please %contact_support%.
|
2019-11-13 19:11:51 +01:00
|
|
|
</I18nMessage>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2022-03-21 14:50:51 +01:00
|
|
|
// **************************************************************************
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
let finalUris;
|
|
|
|
|
|
|
|
if (uris) {
|
|
|
|
// --- direct uris
|
|
|
|
finalUris = uris;
|
2022-03-25 08:53:04 +01:00
|
|
|
injectPinUrls(finalUris, orderParam, pins, resolvedPinUris);
|
2022-03-30 03:17:26 +02:00
|
|
|
finalUris = filterExcludedUris(finalUris, excludeUris);
|
2022-03-21 14:50:51 +01:00
|
|
|
} else {
|
|
|
|
// --- searched uris
|
|
|
|
if (isUnfetchedClaimSearch && prevUris.current) {
|
|
|
|
finalUris = prevUris.current;
|
|
|
|
} else {
|
|
|
|
finalUris = claimSearchResult;
|
2022-03-25 08:53:04 +01:00
|
|
|
injectPinUrls(finalUris, orderParam, pins, resolvedPinUris);
|
2022-03-30 03:17:26 +02:00
|
|
|
finalUris = filterExcludedUris(finalUris, excludeUris);
|
2022-03-21 14:50:51 +01:00
|
|
|
prevUris.current = finalUris;
|
|
|
|
}
|
|
|
|
}
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
|
2021-08-16 22:45:04 +02:00
|
|
|
// **************************************************************************
|
|
|
|
// Helpers
|
|
|
|
// **************************************************************************
|
|
|
|
|
2020-06-18 11:18:25 +02:00
|
|
|
// Returns true if the change in 'options' indicate that we are simply scrolling
|
|
|
|
// down to a new page; false otherwise.
|
|
|
|
function isJustScrollingToNewPage(prevOptions, options) {
|
2020-06-23 15:08:06 +02:00
|
|
|
if (!prevOptions) {
|
|
|
|
// It's a new search, or we just popped back from a different view.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-18 11:18:25 +02:00
|
|
|
// Compare every field except for 'page' and 'release_time'.
|
|
|
|
// There might be better ways to achieve this.
|
|
|
|
let tmpPrevOptions = { ...prevOptions };
|
|
|
|
tmpPrevOptions.page = -1;
|
|
|
|
tmpPrevOptions.release_time = '';
|
|
|
|
|
|
|
|
let tmpOptions = { ...options };
|
|
|
|
tmpOptions.page = -1;
|
|
|
|
tmpOptions.release_time = '';
|
|
|
|
|
|
|
|
return JSON.stringify(tmpOptions) === JSON.stringify(tmpPrevOptions);
|
|
|
|
}
|
|
|
|
|
2020-03-12 02:43:52 +01:00
|
|
|
function getParamFromTags(t) {
|
|
|
|
if (t === CS.TAGS_ALL || t === CS.TAGS_FOLLOWED) {
|
|
|
|
return t;
|
|
|
|
} else if (Array.isArray(t)) {
|
|
|
|
return t.join(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-17 22:49:06 +02:00
|
|
|
function handleScrollBottom() {
|
2020-09-30 20:46:17 +02:00
|
|
|
if (maxPages !== undefined && page === maxPages) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-22 14:07:09 +02:00
|
|
|
if (!loading && infiniteScroll) {
|
2020-07-12 08:28:41 +02:00
|
|
|
if (claimSearchResult && !claimSearchResultLastPageReached) {
|
2020-06-15 13:18:15 +02:00
|
|
|
setPage(page + 1);
|
|
|
|
}
|
2019-07-17 22:49:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-05 19:20:10 +02:00
|
|
|
function resolveHideReposts(hideRepostSetting, hideRepostOverride) {
|
|
|
|
if (hideRepostOverride === undefined || hideRepostOverride === null) {
|
|
|
|
return hideRepostSetting;
|
|
|
|
} else {
|
|
|
|
return hideRepostOverride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-13 17:23:53 +02:00
|
|
|
function resolveOrderByOption(orderBy: string | Array<string>, sortBy: string | Array<string>) {
|
2021-12-16 22:59:13 +01:00
|
|
|
let order_by;
|
|
|
|
|
|
|
|
switch (orderBy) {
|
|
|
|
case CS.ORDER_BY_TRENDING:
|
|
|
|
order_by = CS.ORDER_BY_TRENDING_VALUE;
|
|
|
|
break;
|
|
|
|
case CS.ORDER_BY_NEW:
|
|
|
|
order_by = CS.ORDER_BY_NEW_VALUE;
|
|
|
|
break;
|
|
|
|
case CS.ORDER_BY_NEW_ASC:
|
|
|
|
order_by = CS.ORDER_BY_NEW_ASC_VALUE;
|
|
|
|
break;
|
2022-02-28 06:54:07 +01:00
|
|
|
case CS.ORDER_BY_NAME_ASC:
|
|
|
|
order_by = CS.ORDER_BY_NAME_ASC_VALUE;
|
|
|
|
break;
|
2021-12-16 22:59:13 +01:00
|
|
|
default:
|
|
|
|
order_by = CS.ORDER_BY_TOP_VALUE;
|
|
|
|
}
|
2021-09-13 17:23:53 +02:00
|
|
|
|
|
|
|
if (orderBy === CS.ORDER_BY_NEW && sortBy === CS.SORT_BY.OLDEST.key) {
|
|
|
|
return order_by.map((x) => `${CS.SORT_BY.OLDEST.opt}${x}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return order_by;
|
|
|
|
}
|
|
|
|
|
2022-03-25 08:53:04 +01:00
|
|
|
function injectPinUrls(uris, order, pins, resolvedPinUris) {
|
|
|
|
if (!pins || !uris || uris.length <= 2 || (pins.onlyPinForOrder && pins.onlyPinForOrder !== order)) {
|
2021-12-01 16:18:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-25 08:53:04 +01:00
|
|
|
if (resolvedPinUris) {
|
|
|
|
resolvedPinUris.forEach((pin) => {
|
2021-12-01 16:18:57 +01:00
|
|
|
if (uris.includes(pin)) {
|
|
|
|
uris.splice(uris.indexOf(pin), 1);
|
|
|
|
} else {
|
|
|
|
uris.pop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-03-25 08:53:04 +01:00
|
|
|
uris.splice(2, 0, ...resolvedPinUris);
|
2021-12-01 16:18:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 14:50:51 +01:00
|
|
|
function filterExcludedUris(uris, excludeUris) {
|
|
|
|
if (uris && excludeUris && excludeUris.length) {
|
2022-03-30 03:17:26 +02:00
|
|
|
return uris.filter((uri) => !excludeUris.includes(uri));
|
2022-03-21 14:50:51 +01:00
|
|
|
}
|
2022-03-30 03:17:26 +02:00
|
|
|
return uris;
|
2022-03-21 14:50:51 +01:00
|
|
|
}
|
|
|
|
|
2022-05-23 11:32:57 +02:00
|
|
|
function onHidden(uri) {
|
|
|
|
if (hiddenBuffer.indexOf(uri) === -1) {
|
|
|
|
let newBuffer = hiddenBuffer;
|
|
|
|
newBuffer.push(uri);
|
|
|
|
setHiddenBuffer(newBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-16 22:45:04 +02:00
|
|
|
// **************************************************************************
|
|
|
|
// **************************************************************************
|
2022-03-21 14:50:51 +01:00
|
|
|
|
|
|
|
useFetchViewCount(fetchViewCount, finalUris, claimsByUri, doFetchViewCount);
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
|
2022-03-25 07:36:24 +01:00
|
|
|
useGetUserMemberships(true, finalUris, claimsByUri, doFetchUserMemberships);
|
2022-03-09 19:05:37 +01:00
|
|
|
|
2020-08-21 17:49:13 +02:00
|
|
|
React.useEffect(() => {
|
2019-07-17 22:49:06 +02:00
|
|
|
if (shouldPerformSearch) {
|
|
|
|
const searchOptions = JSON.parse(optionsStringForEffect);
|
|
|
|
doClaimSearch(searchOptions);
|
|
|
|
}
|
2019-11-13 19:11:51 +01:00
|
|
|
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, forceRefresh]);
|
2019-07-17 22:49:06 +02:00
|
|
|
|
2020-08-21 17:49:13 +02:00
|
|
|
const headerToUse = header || (
|
|
|
|
<ClaimListHeader
|
|
|
|
channelIds={channelIds}
|
|
|
|
defaultTags={defaultTags}
|
|
|
|
tags={tags}
|
|
|
|
freshness={freshness}
|
|
|
|
defaultFreshness={defaultFreshness}
|
|
|
|
claimType={claimType}
|
|
|
|
streamType={streamType}
|
|
|
|
defaultStreamType={defaultStreamType}
|
2021-07-21 16:51:26 +02:00
|
|
|
feeAmount={feeAmount} // ENABLE_PAID_CONTENT_DISCOVER or something
|
2020-08-21 17:49:13 +02:00
|
|
|
orderBy={orderBy}
|
|
|
|
defaultOrderBy={defaultOrderBy}
|
2020-09-30 20:46:17 +02:00
|
|
|
hideAdvancedFilter={hideAdvancedFilter}
|
2020-08-21 17:49:13 +02:00
|
|
|
hasMatureTags={hasMatureTags}
|
|
|
|
hiddenNsfwMessage={hiddenNsfwMessage}
|
|
|
|
setPage={setPage}
|
|
|
|
tileLayout={tileLayout}
|
2021-12-16 22:59:13 +01:00
|
|
|
hideLayoutButton={hideLayoutButton}
|
2020-10-02 19:48:28 +02:00
|
|
|
hideFilters={hideFilters}
|
2020-11-25 18:09:58 +01:00
|
|
|
scrollAnchor={scrollAnchor}
|
2020-08-21 17:49:13 +02:00
|
|
|
/>
|
2019-06-11 20:10:58 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2020-01-02 21:36:03 +01:00
|
|
|
<React.Fragment>
|
2020-05-11 17:54:39 +02:00
|
|
|
{headerLabel && <label className="claim-list__header-label">{headerLabel}</label>}
|
2020-08-21 17:49:13 +02:00
|
|
|
{tileLayout ? (
|
|
|
|
<div>
|
2022-02-25 09:48:45 +01:00
|
|
|
{!repostedClaimId && showHeader && (
|
2020-08-21 17:49:13 +02:00
|
|
|
<div className="section__header--actions">
|
2022-02-25 09:48:45 +01:00
|
|
|
<div className="section__actions">
|
|
|
|
{headerToUse}
|
2022-04-22 08:32:56 +02:00
|
|
|
{searchInSelectedLang && <LangFilterIndicator />}
|
2022-02-25 09:48:45 +01:00
|
|
|
</div>
|
2020-11-13 21:25:18 +01:00
|
|
|
{meta && <div className="section__actions--no-margin">{meta}</div>}
|
2020-08-21 17:49:13 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2022-02-28 11:02:47 +01:00
|
|
|
{subSection && <div>{subSection}</div>}
|
2020-08-21 17:49:13 +02:00
|
|
|
<ClaimList
|
|
|
|
tileLayout
|
|
|
|
loading={loading}
|
2022-03-21 14:50:51 +01:00
|
|
|
uris={finalUris}
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
prefixUris={prefixUris}
|
2020-08-21 17:49:13 +02:00
|
|
|
onScrollBottom={handleScrollBottom}
|
|
|
|
page={page}
|
2020-09-08 22:41:05 +02:00
|
|
|
pageSize={dynamicPageSize}
|
2020-08-21 17:49:13 +02:00
|
|
|
timedOutMessage={timedOutMessage}
|
|
|
|
renderProperties={renderProperties}
|
|
|
|
includeSupportAction={includeSupportAction}
|
|
|
|
injectedItem={injectedItem}
|
2021-03-03 19:50:16 +01:00
|
|
|
showHiddenByUser={showHiddenByUser}
|
2021-04-29 10:17:06 +02:00
|
|
|
searchOptions={options}
|
2021-07-07 20:21:11 +02:00
|
|
|
showNoSourceClaims={showNoSourceClaims}
|
2021-06-15 22:06:57 +02:00
|
|
|
empty={empty}
|
2021-12-16 22:59:13 +01:00
|
|
|
maxClaimRender={maxClaimRender}
|
|
|
|
loadedCallback={loadedCallback}
|
2022-01-06 22:13:26 +01:00
|
|
|
swipeLayout={swipeLayout}
|
2022-05-23 11:32:57 +02:00
|
|
|
onHidden={onHidden}
|
2020-08-21 17:49:13 +02:00
|
|
|
/>
|
2021-12-16 22:59:13 +01:00
|
|
|
{loading && useSkeletonScreen && (
|
2020-08-26 23:16:45 +02:00
|
|
|
<div className="claim-grid">
|
2020-09-08 22:41:05 +02:00
|
|
|
{new Array(dynamicPageSize).fill(1).map((x, i) => (
|
2022-05-18 13:16:35 +02:00
|
|
|
<ClaimPreviewTile key={i} placeholder="loading" pulse />
|
2020-08-26 23:16:45 +02:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-08-21 17:49:13 +02:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div>
|
2021-04-06 20:59:12 +02:00
|
|
|
{showHeader && (
|
2021-04-08 17:21:45 +02:00
|
|
|
<div className="section__header--actions">
|
2022-02-25 09:48:45 +01:00
|
|
|
<div className="section__actions">
|
|
|
|
{headerToUse}
|
2022-04-22 08:32:56 +02:00
|
|
|
{searchInSelectedLang && <LangFilterIndicator />}
|
2022-02-25 09:48:45 +01:00
|
|
|
</div>
|
2021-04-08 17:21:45 +02:00
|
|
|
{meta && <div className="section__actions--no-margin">{meta}</div>}
|
|
|
|
</div>
|
2021-04-06 20:59:12 +02:00
|
|
|
)}
|
2022-02-28 11:02:47 +01:00
|
|
|
{subSection && <div>{subSection}</div>}
|
2020-08-21 17:49:13 +02:00
|
|
|
<ClaimList
|
2021-04-06 20:59:12 +02:00
|
|
|
type={type}
|
2020-08-21 17:49:13 +02:00
|
|
|
loading={loading}
|
2022-03-21 14:50:51 +01:00
|
|
|
uris={finalUris}
|
Livestream category improvements (#7115)
* ❌ Remove old method of displaying active livestreams
Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.
* Fetch and store active-livestream info in redux
* Tiles can now query active-livestream state from redux instead of getting from parent.
* ⏪ ClaimTilesDiscover: revert and cleanup
## Simplify
- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.
## Fix
- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....
* ClaimTilesDiscover: factor out options
## Change
Move the `option` code outside and passed in as a pre-calculated prop.
## Reason
To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.
Instead of calculating `options` twice, we moved it to the props so both sides can use it.
It also makes the component a bit more readable.
The downside is that the prop-passing might not be clear.
* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.
* ClaimTilesDiscover: fill with placeholder while waiting for claim_search
## Issue
Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).
## Fix
Fill up the space with placeholders to prevent layout shift.
* Add 'useFetchViewCount' to handle fetching from lists
This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).
* ⏪ ClaimListDiscover: revert and cleanup
## Revert
- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.
## Alterations
- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.
* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover
This will be initially used to append livestreams at the top.
* ✅ Re-enable active livestream tiles using the new method
* doFetchActiveLivestreams: add interval check
- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
* doFetchActiveLivestreams: add option check
We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.
* WildWest: limit livestream tiles + add ability to show more
Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.
This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
* Use better tile-count on larger screens.
Used the same method as how the homepage does it.
2021-09-24 16:26:21 +02:00
|
|
|
prefixUris={prefixUris}
|
2020-08-21 17:49:13 +02:00
|
|
|
onScrollBottom={handleScrollBottom}
|
|
|
|
page={page}
|
2020-09-08 22:41:05 +02:00
|
|
|
pageSize={dynamicPageSize}
|
2020-08-21 17:49:13 +02:00
|
|
|
timedOutMessage={timedOutMessage}
|
|
|
|
renderProperties={renderProperties}
|
|
|
|
includeSupportAction={includeSupportAction}
|
|
|
|
injectedItem={injectedItem}
|
2021-03-03 19:50:16 +01:00
|
|
|
showHiddenByUser={showHiddenByUser}
|
2021-04-29 10:17:06 +02:00
|
|
|
searchOptions={options}
|
2021-08-27 16:57:54 +02:00
|
|
|
showNoSourceClaims={hasNoSource || showNoSourceClaims}
|
2021-06-10 23:01:32 +02:00
|
|
|
empty={empty}
|
2021-12-16 22:59:13 +01:00
|
|
|
maxClaimRender={maxClaimRender}
|
|
|
|
loadedCallback={loadedCallback}
|
2022-01-06 22:13:26 +01:00
|
|
|
swipeLayout={swipeLayout}
|
2022-05-23 11:32:57 +02:00
|
|
|
onHidden={onHidden}
|
2020-08-21 17:49:13 +02:00
|
|
|
/>
|
2021-04-08 17:21:45 +02:00
|
|
|
{loading &&
|
2021-12-16 22:59:13 +01:00
|
|
|
useSkeletonScreen &&
|
2021-04-08 17:21:45 +02:00
|
|
|
new Array(dynamicPageSize)
|
|
|
|
.fill(1)
|
2021-08-27 16:57:54 +02:00
|
|
|
.map((x, i) => (
|
|
|
|
<ClaimPreview
|
|
|
|
showNoSourceClaims={hasNoSource || showNoSourceClaims}
|
|
|
|
key={i}
|
|
|
|
placeholder="loading"
|
|
|
|
type={type}
|
|
|
|
/>
|
|
|
|
))}
|
2020-08-21 17:49:13 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2020-01-02 21:36:03 +01:00
|
|
|
</React.Fragment>
|
2019-06-11 20:10:58 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-07-17 22:49:06 +02:00
|
|
|
export default withRouter(ClaimListDiscover);
|