2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2021-12-10 05:28:37 +01:00
|
|
|
import { MAIN_CLASS } from 'constants/classnames';
|
2019-06-17 22:32:38 +02:00
|
|
|
import type { Node } from 'react';
|
2020-06-23 17:22:30 +02:00
|
|
|
import React, { useEffect } from 'react';
|
2019-06-11 20:10:58 +02:00
|
|
|
import classnames from 'classnames';
|
2019-06-28 09:27:55 +02:00
|
|
|
import ClaimPreview from 'component/claimPreview';
|
2019-06-11 20:10:58 +02:00
|
|
|
import Spinner from 'component/spinner';
|
|
|
|
import { FormField } from 'component/common/form';
|
2019-09-27 20:56:15 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2022-04-18 10:59:59 +02:00
|
|
|
import useGetLastVisibleSlot from 'effects/use-get-last-visible-slot';
|
2020-06-23 14:56:38 +02:00
|
|
|
import debounce from 'util/debounce';
|
2020-08-21 17:49:13 +02:00
|
|
|
import ClaimPreviewTile from 'component/claimPreviewTile';
|
2019-06-11 20:10:58 +02:00
|
|
|
|
2022-02-14 20:54:23 +01:00
|
|
|
const Draggable = React.lazy(() =>
|
|
|
|
// $FlowFixMe
|
|
|
|
import('react-beautiful-dnd' /* webpackChunkName: "dnd" */).then((module) => ({ default: module.Draggable }))
|
|
|
|
);
|
|
|
|
|
2020-06-23 14:56:38 +02:00
|
|
|
const DEBOUNCE_SCROLL_HANDLER_MS = 150;
|
2019-06-11 20:10:58 +02:00
|
|
|
const SORT_NEW = 'new';
|
|
|
|
const SORT_OLD = 'old';
|
2018-03-26 23:32:43 +02:00
|
|
|
|
|
|
|
type Props = {
|
2019-06-11 20:10:58 +02:00
|
|
|
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>,
|
2019-06-19 07:05:43 +02:00
|
|
|
header: Node | boolean,
|
2019-06-17 22:32:38 +02:00
|
|
|
headerAltControls: Node,
|
2019-06-11 20:10:58 +02:00
|
|
|
loading: boolean,
|
2022-03-02 14:07:35 +01:00
|
|
|
useLoadingSpinner?: boolean, // use built-in spinner when 'loading' is true. Else, roll your own at client-side.
|
2019-06-19 07:05:43 +02:00
|
|
|
type: string,
|
2021-07-13 00:39:23 +02:00
|
|
|
activeUri?: string,
|
2019-06-11 20:10:58 +02:00
|
|
|
empty?: string,
|
2019-06-28 09:33:07 +02:00
|
|
|
defaultSort?: boolean,
|
2021-02-18 09:55:29 +01:00
|
|
|
onScrollBottom?: (any) => void,
|
2019-07-01 06:35:36 +02:00
|
|
|
page?: number,
|
2019-07-02 04:54:11 +02:00
|
|
|
pageSize?: number,
|
2019-06-11 20:10:58 +02:00
|
|
|
// If using the default header, this is a unique ID needed to persist the state of the filter setting
|
|
|
|
persistedStorageKey?: string,
|
2019-08-02 02:56:25 +02:00
|
|
|
showHiddenByUser: boolean,
|
2020-02-05 19:01:07 +01:00
|
|
|
showUnresolvedClaims?: boolean,
|
2021-04-23 21:59:48 +02:00
|
|
|
renderActions?: (Claim) => ?Node,
|
|
|
|
renderProperties?: (Claim) => ?Node,
|
2020-02-12 19:59:48 +01:00
|
|
|
includeSupportAction?: boolean,
|
2022-03-07 13:11:28 +01:00
|
|
|
injectedItem?: { node: Node, index?: number, replace?: boolean },
|
2020-03-31 18:07:57 +02:00
|
|
|
timedOutMessage?: Node,
|
2020-08-21 17:49:13 +02:00
|
|
|
tileLayout?: boolean,
|
2021-02-18 09:55:29 +01:00
|
|
|
searchInLanguage: boolean,
|
2021-03-03 19:50:16 +01:00
|
|
|
hideMenu?: boolean,
|
2021-04-29 09:22:56 +02:00
|
|
|
claimSearchByQuery: { [string]: Array<string> },
|
|
|
|
claimsByUri: { [string]: any },
|
wip
wip
wip - everything but publish, autoplay, and styling
collection publishing
add channel to collection publish
cleanup
wip
bump
clear mass add after success
move collection item management controls
redirect replace to published collection id
bump
playlist selector on create
bump
use new collection add ui element
bump
wip
gitignore
add content json
wip
bump
context add to playlist
basic collections page style pass wip
wip: edits, buttons, styles...
change fileAuthor to claimAuthor
update, pending bugfixes, delete modal progress, collection header, other bugfixes
bump
cleaning
show page bugfix
builtin collection headers
no playlists, no grid title
wip
style tweaks
use normal looking claim previews for collection tiles
add collection changes
style library previews
collection menulist for delete/view on library
delete modal works for unpublished
rearrange collection publish tabs
clean up collection publishing and items
show on odysee
begin collectoin edit header and css renaming
better thumbnails
bump
fix collection publish redirect
view collection in menu does something
copy and thumbs
list previews, pending, context menus, list page
enter to add collection, lists page empty state
playable lists only, delete feature, bump
put fileListDownloaded back
better collection titles
improve collection claim details
fix horiz more icon
fix up channel page
style, copy, bump
refactor preview overlay properties,
fix reposts showing as floppydisk
add watch later toast,
small overlay properties on wunderbar results,
fix collection actions buttons
bump
cleanup
cleaning, refactoring
bump
preview thumb styling, cleanup
support discover page lists search
sync, bump
bump, fix sync more
enforce builtin order for now
new lists page empty state
try to indicate unpublished edits in lists
bump
fix autoplay and linting
consts, fix autoplay
bugs
fixes
cleanup
fix, bump
lists experimental ui, fixes
refactor listIndex out
hack in collection fallback thumb
bump
2021-02-06 08:03:51 +01:00
|
|
|
collectionId?: string,
|
2022-03-15 20:07:31 +01:00
|
|
|
fypId?: string,
|
2021-07-07 20:21:11 +02:00
|
|
|
showNoSourceClaims?: boolean,
|
2021-09-03 00:39:40 +02:00
|
|
|
onClick?: (e: any, claim?: ?Claim, index?: number) => void,
|
2022-04-05 18:38:11 +02:00
|
|
|
noEmpty?: boolean,
|
2021-12-16 22:59:13 +01:00
|
|
|
maxClaimRender?: number,
|
|
|
|
loadedCallback?: (number) => void,
|
2022-01-06 22:13:26 +01:00
|
|
|
swipeLayout: boolean,
|
2022-01-12 20:14:12 +01:00
|
|
|
showEdit?: boolean,
|
|
|
|
droppableProvided?: any,
|
|
|
|
unavailableUris?: Array<string>,
|
2022-03-09 19:05:37 +01:00
|
|
|
showMemberBadge?: boolean,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
2019-06-19 07:05:43 +02:00
|
|
|
export default function ClaimList(props: Props) {
|
2019-06-27 08:18:45 +02:00
|
|
|
const {
|
2021-07-13 00:39:23 +02:00
|
|
|
activeUri,
|
2019-06-27 08:18:45 +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,
|
2019-06-27 08:18:45 +02:00
|
|
|
headerAltControls,
|
|
|
|
loading,
|
2022-03-02 14:07:35 +01:00
|
|
|
useLoadingSpinner,
|
2019-06-27 08:18:45 +02:00
|
|
|
persistedStorageKey,
|
|
|
|
empty,
|
2019-06-28 09:33:07 +02:00
|
|
|
defaultSort,
|
2019-06-27 08:18:45 +02:00
|
|
|
type,
|
|
|
|
header,
|
|
|
|
onScrollBottom,
|
2019-07-02 04:54:11 +02:00
|
|
|
pageSize,
|
2019-07-23 10:05:51 +02:00
|
|
|
page,
|
2019-08-02 02:56:25 +02:00
|
|
|
showHiddenByUser,
|
2020-02-05 19:01:07 +01:00
|
|
|
showUnresolvedClaims,
|
2020-02-12 19:59:48 +01:00
|
|
|
includeSupportAction,
|
2020-03-26 22:47:07 +01:00
|
|
|
injectedItem,
|
2020-03-31 18:07:57 +02:00
|
|
|
timedOutMessage,
|
2020-08-21 17:49:13 +02:00
|
|
|
tileLayout = false,
|
2020-10-12 23:12:46 +02:00
|
|
|
renderActions,
|
2021-04-23 21:59:48 +02:00
|
|
|
renderProperties,
|
2021-02-18 09:55:29 +01:00
|
|
|
searchInLanguage,
|
2021-03-03 19:50:16 +01:00
|
|
|
hideMenu,
|
wip
wip
wip - everything but publish, autoplay, and styling
collection publishing
add channel to collection publish
cleanup
wip
bump
clear mass add after success
move collection item management controls
redirect replace to published collection id
bump
playlist selector on create
bump
use new collection add ui element
bump
wip
gitignore
add content json
wip
bump
context add to playlist
basic collections page style pass wip
wip: edits, buttons, styles...
change fileAuthor to claimAuthor
update, pending bugfixes, delete modal progress, collection header, other bugfixes
bump
cleaning
show page bugfix
builtin collection headers
no playlists, no grid title
wip
style tweaks
use normal looking claim previews for collection tiles
add collection changes
style library previews
collection menulist for delete/view on library
delete modal works for unpublished
rearrange collection publish tabs
clean up collection publishing and items
show on odysee
begin collectoin edit header and css renaming
better thumbnails
bump
fix collection publish redirect
view collection in menu does something
copy and thumbs
list previews, pending, context menus, list page
enter to add collection, lists page empty state
playable lists only, delete feature, bump
put fileListDownloaded back
better collection titles
improve collection claim details
fix horiz more icon
fix up channel page
style, copy, bump
refactor preview overlay properties,
fix reposts showing as floppydisk
add watch later toast,
small overlay properties on wunderbar results,
fix collection actions buttons
bump
cleanup
cleaning, refactoring
bump
preview thumb styling, cleanup
support discover page lists search
sync, bump
bump, fix sync more
enforce builtin order for now
new lists page empty state
try to indicate unpublished edits in lists
bump
fix autoplay and linting
consts, fix autoplay
bugs
fixes
cleanup
fix, bump
lists experimental ui, fixes
refactor listIndex out
hack in collection fallback thumb
bump
2021-02-06 08:03:51 +01:00
|
|
|
collectionId,
|
2022-03-15 20:07:31 +01:00
|
|
|
fypId,
|
2021-07-07 20:21:11 +02:00
|
|
|
showNoSourceClaims,
|
Fill in remaining Recsys fields
## Issue
6366 Recsys Evaluation Telemetry
The recommended list from lighthouse is obtained from `makeSelectRecommendedContentForUri`. This list is further tweaked by the GUI (e.g. move autoplay next item to top, remove blocked content, etc.). Recsys wants the final recommendation list and the clicked index (in exact order), so we need pass these info to the videojs recsys plugin somehow. Also, Recsys wants a recommendation list ID as well as the parent (referrer) ID, we so need to track the clicks and navigation.
## General Approach
- It seems easiest to just spew back the final (displayed) list and all the required info to Redux, and the recsys plugin (or anyone else in the future) can grab it.
- Try to touch few files as possible. The dirty work should all reside in `<RecommendedContent>` only.
## Changes
- `ClaimPreview`: add optional parameters to store an ID of the container that it is in (for this case, it is `ClaimList`) as well as the index within the container.
- When clicked, we store the container ID in the navigation history `state` object.
- For general cases, anyone can check this state from `history.location.state` to know which container referred/navigated to the current page. For the recsys use case, we can use this as the `parentUUID`.
- `ClaimList`: just relay `onClick` and set IDs.
- `RecommendedContent`: now handles the uuid generation (for both parent and child) and stores the data in Redux.
2021-07-28 14:07:49 +02:00
|
|
|
onClick,
|
2022-04-05 18:38:11 +02:00
|
|
|
noEmpty,
|
2021-12-16 22:59:13 +01:00
|
|
|
maxClaimRender,
|
|
|
|
loadedCallback,
|
2022-01-06 22:13:26 +01:00
|
|
|
swipeLayout = false,
|
2022-01-12 20:14:12 +01:00
|
|
|
showEdit,
|
|
|
|
droppableProvided,
|
|
|
|
unavailableUris,
|
2022-03-09 19:05:37 +01:00
|
|
|
showMemberBadge,
|
2019-06-27 08:18:45 +02:00
|
|
|
} = props;
|
2020-08-21 17:49:13 +02:00
|
|
|
|
2019-06-11 20:38:08 +02:00
|
|
|
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
|
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-08 18:51:41 +01:00
|
|
|
// Resolve the index for injectedItem, if provided; else injectedIndex will be 'undefined'.
|
2022-03-07 13:11:28 +01:00
|
|
|
const listRef = React.useRef();
|
2022-04-18 10:59:59 +02:00
|
|
|
const injectedIndex = useGetLastVisibleSlot(injectedItem, listRef);
|
2022-03-07 13:11:28 +01: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
|
|
|
// Exclude prefix uris in these results variables. We don't want to show
|
|
|
|
// anything if the search failed or timed out.
|
2020-03-31 18:07:57 +02:00
|
|
|
const timedOut = uris === null;
|
2019-07-17 22:49:06 +02:00
|
|
|
const urisLength = (uris && uris.length) || 0;
|
2021-04-29 09:22:56 +02:00
|
|
|
|
2021-12-16 22:59:13 +01:00
|
|
|
let tileUris = (prefixUris || []).concat(uris || []);
|
2022-03-20 08:13:30 +01:00
|
|
|
|
2022-02-11 19:50:55 +01:00
|
|
|
if (prefixUris && prefixUris.length) tileUris.splice(prefixUris.length * -1, prefixUris.length);
|
2021-12-17 22:28:11 +01:00
|
|
|
|
|
|
|
const totalLength = tileUris.length;
|
|
|
|
|
2021-12-16 22:59:13 +01:00
|
|
|
if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender);
|
|
|
|
|
2022-03-20 08:13:30 +01:00
|
|
|
const sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || [];
|
2021-12-16 22:59:13 +01:00
|
|
|
|
|
|
|
React.useEffect(() => {
|
2021-12-17 22:28:11 +01:00
|
|
|
if (typeof loadedCallback === 'function') loadedCallback(totalLength);
|
|
|
|
}, [totalLength]); // eslint-disable-line react-hooks/exhaustive-deps
|
2021-04-29 09:22:56 +02:00
|
|
|
|
2021-02-18 09:55:29 +01:00
|
|
|
const noResultMsg = searchInLanguage
|
|
|
|
? __('No results. Contents may be hidden by the Language filter.')
|
|
|
|
: __('No results');
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
function handleSortChange() {
|
|
|
|
setCurrentSort(currentSort === SORT_NEW ? SORT_OLD : SORT_NEW);
|
2017-04-30 18:01:43 +02:00
|
|
|
}
|
2017-04-23 18:10:45 +02:00
|
|
|
|
2021-10-22 06:19:02 +02:00
|
|
|
const handleClaimClicked = React.useCallback(
|
|
|
|
(e, claim, index) => {
|
|
|
|
if (onClick) {
|
|
|
|
onClick(e, claim, index);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[onClick]
|
|
|
|
);
|
|
|
|
|
|
|
|
const customShouldHide = React.useCallback((claim: StreamClaim) => {
|
|
|
|
// Hack to hide spee.ch thumbnail publishes
|
|
|
|
// If it meets these requirements, it was probably uploaded here:
|
|
|
|
// https://github.com/lbryio/lbry-redux/blob/master/src/redux/actions/publish.js#L74-L79
|
|
|
|
return claim.name.length === 24 && !claim.name.includes(' ') && claim.value.author === 'Spee.ch';
|
|
|
|
}, []);
|
Fill in remaining Recsys fields
## Issue
6366 Recsys Evaluation Telemetry
The recommended list from lighthouse is obtained from `makeSelectRecommendedContentForUri`. This list is further tweaked by the GUI (e.g. move autoplay next item to top, remove blocked content, etc.). Recsys wants the final recommendation list and the clicked index (in exact order), so we need pass these info to the videojs recsys plugin somehow. Also, Recsys wants a recommendation list ID as well as the parent (referrer) ID, we so need to track the clicks and navigation.
## General Approach
- It seems easiest to just spew back the final (displayed) list and all the required info to Redux, and the recsys plugin (or anyone else in the future) can grab it.
- Try to touch few files as possible. The dirty work should all reside in `<RecommendedContent>` only.
## Changes
- `ClaimPreview`: add optional parameters to store an ID of the container that it is in (for this case, it is `ClaimList`) as well as the index within the container.
- When clicked, we store the container ID in the navigation history `state` object.
- For general cases, anyone can check this state from `history.location.state` to know which container referred/navigated to the current page. For the recsys use case, we can use this as the `parentUUID`.
- `ClaimList`: just relay `onClick` and set IDs.
- `RecommendedContent`: now handles the uuid generation (for both parent and child) and stores the data in Redux.
2021-07-28 14:07:49 +02:00
|
|
|
|
2022-03-07 13:11:28 +01:00
|
|
|
// @if process.env.NODE_ENV!='production'
|
|
|
|
if (injectedItem && injectedItem.replace) {
|
|
|
|
throw new Error('claimList: "injectedItem.replace" is not implemented yet');
|
|
|
|
}
|
|
|
|
// @endif
|
|
|
|
|
2019-06-27 08:18:45 +02:00
|
|
|
useEffect(() => {
|
2021-02-18 09:55:29 +01:00
|
|
|
const handleScroll = debounce((e) => {
|
2020-06-23 17:22:30 +02:00
|
|
|
if (page && pageSize && onScrollBottom) {
|
2020-07-02 07:38:25 +02:00
|
|
|
const mainEl = document.querySelector(`.${MAIN_CLASS}`);
|
|
|
|
if (mainEl && !loading && urisLength >= pageSize) {
|
2022-01-11 14:26:44 +01:00
|
|
|
const ROUGH_TILE_HEIGHT_PX = 200;
|
|
|
|
const mainBoundingRect = mainEl.getBoundingClientRect();
|
|
|
|
const contentWrapperAtBottomOfPage = mainBoundingRect.bottom - ROUGH_TILE_HEIGHT_PX <= window.innerHeight;
|
2020-06-23 14:56:38 +02:00
|
|
|
if (contentWrapperAtBottomOfPage) {
|
|
|
|
onScrollBottom();
|
2020-02-26 21:48:28 +01:00
|
|
|
}
|
2019-06-28 09:33:07 +02:00
|
|
|
}
|
2020-06-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
}, DEBOUNCE_SCROLL_HANDLER_MS);
|
2019-06-28 09:33:07 +02:00
|
|
|
|
2019-06-27 08:18:45 +02:00
|
|
|
if (onScrollBottom) {
|
|
|
|
window.addEventListener('scroll', handleScroll);
|
2020-06-23 14:56:38 +02:00
|
|
|
return () => window.removeEventListener('scroll', handleScroll);
|
2019-06-27 08:18:45 +02:00
|
|
|
}
|
2020-06-23 17:22:30 +02:00
|
|
|
}, [loading, onScrollBottom, urisLength, pageSize, page]);
|
2019-06-27 08:18:45 +02:00
|
|
|
|
2022-01-12 20:14:12 +01:00
|
|
|
const getClaimPreview = (uri: string, index: number, draggableProvided?: any) => (
|
|
|
|
<ClaimPreview
|
|
|
|
uri={uri}
|
2022-01-19 14:48:20 +01:00
|
|
|
key={uri}
|
2022-01-12 20:14:12 +01:00
|
|
|
indexInContainer={index}
|
|
|
|
type={type}
|
|
|
|
active={activeUri && uri === activeUri}
|
|
|
|
hideMenu={hideMenu}
|
|
|
|
includeSupportAction={includeSupportAction}
|
|
|
|
showUnresolvedClaim={showUnresolvedClaims}
|
|
|
|
properties={renderProperties || (type !== 'small' ? undefined : false)}
|
|
|
|
renderActions={renderActions}
|
|
|
|
showUserBlocked={showHiddenByUser}
|
|
|
|
showHiddenByUser={showHiddenByUser}
|
|
|
|
collectionId={collectionId}
|
|
|
|
showNoSourceClaims={showNoSourceClaims}
|
|
|
|
customShouldHide={customShouldHide}
|
|
|
|
onClick={handleClaimClicked}
|
|
|
|
swipeLayout={swipeLayout}
|
|
|
|
showEdit={showEdit}
|
|
|
|
dragHandleProps={draggableProvided && draggableProvided.dragHandleProps}
|
|
|
|
unavailableUris={unavailableUris}
|
2022-03-09 19:05:37 +01:00
|
|
|
showMemberBadge={showMemberBadge}
|
2022-01-12 20:14:12 +01:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2022-03-07 13:11:28 +01:00
|
|
|
const getInjectedItem = (index) => {
|
|
|
|
if (injectedItem && injectedItem.node && injectedIndex === index) {
|
|
|
|
return injectedItem.node;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2020-08-21 17:49:13 +02:00
|
|
|
return tileLayout && !header ? (
|
2022-03-08 18:51:41 +01:00
|
|
|
<>
|
|
|
|
<section ref={listRef} className={classnames('claim-grid', { 'swipe-list': swipeLayout })}>
|
|
|
|
{urisLength > 0 &&
|
|
|
|
tileUris.map((uri, index) => (
|
|
|
|
<React.Fragment key={uri}>
|
|
|
|
{getInjectedItem(index)}
|
|
|
|
<ClaimPreviewTile
|
|
|
|
uri={uri}
|
|
|
|
showHiddenByUser={showHiddenByUser}
|
|
|
|
properties={renderProperties}
|
|
|
|
collectionId={collectionId}
|
2022-03-15 20:07:31 +01:00
|
|
|
fypId={fypId}
|
2022-03-08 18:51:41 +01:00
|
|
|
showNoSourceClaims={showNoSourceClaims}
|
|
|
|
swipeLayout={swipeLayout}
|
|
|
|
/>
|
|
|
|
</React.Fragment>
|
|
|
|
))}
|
2022-04-05 18:38:11 +02:00
|
|
|
{!timedOut && urisLength === 0 && !loading && !noEmpty && (
|
|
|
|
<div className="empty main--empty">{empty || noResultMsg}</div>
|
|
|
|
)}
|
2022-03-08 18:51:41 +01:00
|
|
|
{timedOut && timedOutMessage && <div className="empty main--empty">{timedOutMessage}</div>}
|
|
|
|
</section>
|
|
|
|
{loading && useLoadingSpinner && (
|
|
|
|
<div className="spinnerArea--centered">
|
|
|
|
<Spinner type="small" />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</>
|
2020-08-21 17:49:13 +02:00
|
|
|
) : (
|
2019-06-28 09:33:07 +02:00
|
|
|
<section
|
|
|
|
className={classnames('claim-list', {
|
|
|
|
'claim-list--small': type === 'small',
|
|
|
|
})}
|
|
|
|
>
|
2019-06-19 07:05:43 +02:00
|
|
|
{header !== false && (
|
2020-01-02 21:36:03 +01:00
|
|
|
<React.Fragment>
|
2020-03-19 17:54:37 +01:00
|
|
|
{header && (
|
|
|
|
<div className={classnames('claim-list__header', { 'section__title--small': type === 'small' })}>
|
|
|
|
{header}
|
|
|
|
{loading && <Spinner type="small" />}
|
2021-04-07 07:40:34 +02:00
|
|
|
{(headerAltControls || defaultSort) && (
|
|
|
|
<div className="claim-list__alt-controls">
|
|
|
|
{headerAltControls}
|
|
|
|
{defaultSort && (
|
|
|
|
<FormField
|
|
|
|
className="claim-list__dropdown"
|
|
|
|
type="select"
|
|
|
|
name="file_sort"
|
|
|
|
value={currentSort}
|
|
|
|
onChange={handleSortChange}
|
|
|
|
>
|
|
|
|
<option value={SORT_NEW}>{__('Newest First')}</option>
|
|
|
|
<option value={SORT_OLD}>{__('Oldest First')}</option>
|
|
|
|
</FormField>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-01-02 21:36:03 +01:00
|
|
|
</div>
|
2020-03-19 17:54:37 +01:00
|
|
|
)}
|
2020-01-02 21:36:03 +01:00
|
|
|
</React.Fragment>
|
2019-06-11 20:10:58 +02:00
|
|
|
)}
|
2019-08-19 06:49:54 +02:00
|
|
|
|
2019-07-17 22:49:06 +02:00
|
|
|
{urisLength > 0 && (
|
2020-04-29 21:31:11 +02:00
|
|
|
<ul
|
|
|
|
className={classnames('ul--no-style', {
|
2022-01-06 22:13:26 +01:00
|
|
|
card: !(tileLayout || swipeLayout || type === 'small'),
|
2020-08-21 17:49:13 +02:00
|
|
|
'claim-list--card-body': tileLayout,
|
2022-01-06 22:13:26 +01:00
|
|
|
'swipe-list': swipeLayout,
|
2020-04-29 21:31:11 +02:00
|
|
|
})}
|
2022-01-12 20:14:12 +01:00
|
|
|
{...(droppableProvided && droppableProvided.droppableProps)}
|
2022-03-07 13:11:28 +01:00
|
|
|
ref={droppableProvided ? droppableProvided.innerRef : listRef}
|
2020-04-29 21:31:11 +02:00
|
|
|
>
|
2022-03-07 07:09:23 +01:00
|
|
|
{droppableProvided ? (
|
|
|
|
<>
|
|
|
|
{sortedUris.map((uri, index) => (
|
|
|
|
<React.Suspense fallback={null} key={uri}>
|
|
|
|
<Draggable draggableId={uri} index={index}>
|
|
|
|
{(draggableProvided, draggableSnapshot) => {
|
|
|
|
// Restrict dragging to vertical axis
|
|
|
|
// https://github.com/atlassian/react-beautiful-dnd/issues/958#issuecomment-980548919
|
|
|
|
let transform = draggableProvided.draggableProps.style.transform;
|
|
|
|
if (draggableSnapshot.isDragging && transform) {
|
|
|
|
transform = transform.replace(/\(.+,/, '(0,');
|
|
|
|
}
|
2022-01-12 20:14:12 +01:00
|
|
|
|
2022-03-07 07:09:23 +01:00
|
|
|
const style = {
|
|
|
|
...draggableProvided.draggableProps.style,
|
|
|
|
transform,
|
|
|
|
};
|
2022-01-12 20:14:12 +01:00
|
|
|
|
2022-03-07 07:09:23 +01:00
|
|
|
return (
|
|
|
|
<li ref={draggableProvided.innerRef} {...draggableProvided.draggableProps} style={style}>
|
|
|
|
{/* https://github.com/atlassian/react-beautiful-dnd/issues/1756 */}
|
|
|
|
<div style={{ display: 'none' }} {...draggableProvided.dragHandleProps} />
|
|
|
|
{getClaimPreview(uri, index, draggableProvided)}
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</Draggable>
|
|
|
|
</React.Suspense>
|
|
|
|
))}
|
|
|
|
{droppableProvided.placeholder}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
sortedUris.map((uri, index) => (
|
|
|
|
<React.Fragment key={uri}>
|
2022-03-07 13:11:28 +01:00
|
|
|
{getInjectedItem(index)}
|
2022-03-07 07:09:23 +01:00
|
|
|
{getClaimPreview(uri, index)}
|
|
|
|
</React.Fragment>
|
|
|
|
))
|
2022-01-12 20:14:12 +01:00
|
|
|
)}
|
2019-06-11 20:10:58 +02:00
|
|
|
</ul>
|
|
|
|
)}
|
2020-08-21 17:49:13 +02:00
|
|
|
|
2022-04-05 18:38:11 +02:00
|
|
|
{!timedOut && urisLength === 0 && !loading && !noEmpty && (
|
|
|
|
<div className="empty empty--centered">{empty || noResultMsg}</div>
|
|
|
|
)}
|
2020-09-30 20:46:17 +02:00
|
|
|
{!loading && timedOut && timedOutMessage && <div className="empty empty--centered">{timedOutMessage}</div>}
|
2022-03-02 14:07:35 +01:00
|
|
|
{loading && useLoadingSpinner && (
|
|
|
|
<div className="spinnerArea--centered">
|
|
|
|
<Spinner type="small" />
|
|
|
|
</div>
|
|
|
|
)}
|
2019-06-11 20:10:58 +02:00
|
|
|
</section>
|
|
|
|
);
|
2017-04-30 18:01:43 +02:00
|
|
|
}
|