2019-05-07 04:35:04 +02:00
// @flow
2022-03-10 12:44:11 +01:00
import { SIMPLE _SITE } from 'config' ;
2020-06-18 17:10:46 +02:00
import * as CS from 'constants/claim_search' ;
import * as ICONS from 'constants/icons' ;
2019-05-07 04:35:04 +02:00
import React , { Fragment } from 'react' ;
2022-05-25 07:57:51 +02:00
import GeoRestrictionInfo from 'component/geoRestictionInfo' ;
2019-05-07 04:35:04 +02:00
import HiddenNsfwClaims from 'component/hiddenNsfwClaims' ;
2020-06-18 17:10:46 +02:00
import { useHistory } from 'react-router-dom' ;
2019-08-29 03:39:21 +02:00
import Button from 'component/button' ;
2020-02-28 15:40:18 +01:00
import ClaimListDiscover from 'component/claimListDiscover' ;
2020-05-07 20:44:11 +02:00
import Ads from 'web/component/ads' ;
2020-06-18 17:10:46 +02:00
import Icon from 'component/common/icon' ;
2021-03-19 21:14:31 +01:00
import LivestreamLink from 'component/livestreamLink' ;
2020-06-18 17:10:46 +02:00
import { Form , FormField } from 'component/common/form' ;
2021-12-16 22:59:13 +01:00
import ScheduledStreams from 'component/scheduledStreams' ;
2022-07-05 19:20:10 +02:00
import { ClaimSearchFilterContext } from 'contexts/claimSearchFilterContext' ;
2022-03-08 18:25:39 +01:00
import { SearchResults } from './internal/searchResults' ;
2022-03-16 18:35:27 +01:00
import useFetchLiveStatus from 'effects/use-fetch-live' ;
2022-04-11 16:05:41 +02:00
import { useIsLargeScreen } from 'effects/use-screensize' ;
2022-07-05 19:20:10 +02:00
import usePersistedState from 'effects/use-persisted-state' ;
2019-05-07 04:35:04 +02:00
2021-08-24 03:42:37 +02:00
const TYPES _TO _ALLOW _FILTER = [ 'stream' , 'repost' ] ;
2019-05-07 04:35:04 +02:00
type Props = {
uri : string ,
totalPages : number ,
fetching : boolean ,
params : { page : number } ,
2019-11-22 02:37:25 +01:00
pageOfClaimsInChannel : Array < StreamClaim > ,
2019-07-08 22:54:58 +02:00
channelIsBlocked : boolean ,
2019-05-07 04:35:04 +02:00
channelIsMine : boolean ,
fetchClaims : ( string , number ) => void ,
2019-08-29 03:39:21 +02:00
channelIsBlackListed : boolean ,
2020-04-22 14:07:09 +02:00
defaultPageSize ? : number ,
defaultInfiniteScroll ? : Boolean ,
2021-06-15 22:06:57 +02:00
claim : Claim ,
2020-03-26 22:47:07 +01:00
isAuthenticated : boolean ,
2020-06-18 17:10:46 +02:00
showMature : boolean ,
2020-09-17 19:28:46 +02:00
tileLayout : boolean ,
2021-03-04 18:55:16 +01:00
viewHiddenChannels : boolean ,
2022-02-23 14:23:42 +01:00
doResolveUris : ( Array < string > , boolean ) => void ,
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
claimType : string ,
2021-06-10 23:01:32 +02:00
empty ? : string ,
2022-01-06 18:49:49 +01:00
doFetchChannelLiveStatus : ( string ) => void ,
2021-12-22 17:12:44 +01:00
activeLivestreamForChannel : any ,
activeLivestreamInitialized : boolean ,
2022-05-18 20:51:15 +02:00
hasPremiumPlus : boolean ,
2019-05-07 04:35:04 +02:00
} ;
function ChannelContent ( props : Props ) {
2020-04-22 14:07:09 +02:00
const {
uri ,
fetching ,
channelIsMine ,
channelIsBlocked ,
channelIsBlackListed ,
claim ,
defaultPageSize = CS . PAGE _SIZE ,
defaultInfiniteScroll = true ,
2020-06-18 17:10:46 +02:00
showMature ,
2020-09-17 19:28:46 +02:00
tileLayout ,
2021-03-04 18:55:16 +01:00
viewHiddenChannels ,
2022-02-23 14:23:42 +01:00
doResolveUris ,
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
claimType ,
2021-06-10 23:01:32 +02:00
empty ,
2022-01-06 18:49:49 +01:00
doFetchChannelLiveStatus ,
2021-12-22 17:12:44 +01:00
activeLivestreamForChannel ,
activeLivestreamInitialized ,
2022-05-18 20:51:15 +02:00
hasPremiumPlus ,
2020-04-22 14:07:09 +02:00
} = props ;
2021-10-02 19:58:39 +02:00
// const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0;
2022-03-09 19:05:37 +01:00
2021-10-02 19:58:39 +02:00
const claimsInChannel = 9999 ;
2020-06-18 17:10:46 +02:00
const [ searchQuery , setSearchQuery ] = React . useState ( '' ) ;
2022-03-08 18:25:39 +01:00
const [ isSearching , setIsSearching ] = React . useState ( false ) ;
2020-06-18 17:10:46 +02:00
const {
location : { pathname , search } ,
} = useHistory ( ) ;
2022-07-05 19:20:10 +02:00
// In Channel Page, ignore SETTINGS.HIDE_REPOSTS and show reposts by default:
2022-07-06 16:03:33 +02:00
const [ hideReposts , setHideReposts ] = usePersistedState ( 'hideRepostsChannelPage' , false ) ;
2022-07-05 19:20:10 +02:00
const claimSearchFilterCtx = {
contentTypes : CS . CONTENT _TYPES ,
repost : { hideReposts , setHideReposts } ,
} ;
2020-06-18 17:10:46 +02:00
const url = ` ${ pathname } ${ search } ` ;
const claimId = claim && claim . claim _id ;
2021-12-16 22:59:13 +01:00
const isChannelEmpty = ! claim || ! claim . meta ;
2021-08-24 03:42:37 +02:00
const showFilters =
! claimType ||
( Array . isArray ( claimType )
? claimType . every ( ( ct ) => TYPES _TO _ALLOW _FILTER . includes ( ct ) )
: TYPES _TO _ALLOW _FILTER . includes ( claimType ) ) ;
2022-04-11 16:05:41 +02:00
const isLargeScreen = useIsLargeScreen ( ) ;
const dynamicPageSize = isLargeScreen ? Math . ceil ( defaultPageSize * 3 ) : defaultPageSize ;
2020-06-18 17:10:46 +02:00
2022-07-05 19:20:10 +02:00
const isInitialized = Boolean ( activeLivestreamForChannel ) || activeLivestreamInitialized ;
const isChannelBroadcasting = Boolean ( activeLivestreamForChannel ) ;
const showScheduledLiveStreams = claimType !== 'collection' ; // ie. not on the playlist page.
2020-06-18 17:10:46 +02:00
function handleInputChange ( e ) {
const { value } = e . target ;
setSearchQuery ( value ) ;
}
React . useEffect ( ( ) => {
setSearchQuery ( '' ) ;
} , [ url ] ) ;
2020-02-28 15:40:18 +01:00
2022-06-09 20:43:45 +02:00
useFetchLiveStatus ( claimId , doFetchChannelLiveStatus , true ) ;
2021-12-16 22:59:13 +01:00
2019-05-07 04:35:04 +02:00
return (
< Fragment >
2022-05-25 07:57:51 +02:00
< GeoRestrictionInfo uri = { uri } / >
2020-02-28 15:40:18 +01:00
{ ! fetching && Boolean ( claimsInChannel ) && ! channelIsBlocked && ! channelIsBlackListed && (
< HiddenNsfwClaims uri = { uri } / >
2019-12-13 23:32:20 +01:00
) }
2021-12-16 22:59:13 +01:00
{ ! fetching && isInitialized && isChannelBroadcasting && ! isChannelEmpty && (
2021-12-22 17:12:44 +01:00
< LivestreamLink claimUri = { activeLivestreamForChannel . claimUri } / >
2021-12-16 22:59:13 +01:00
) }
{ ! fetching && showScheduledLiveStreams && (
< ScheduledStreams
channelIds = { [ claimId ] }
tileLayout = { tileLayout }
liveUris = {
2021-12-22 17:12:44 +01:00
isChannelBroadcasting && activeLivestreamForChannel . claimUri ? [ activeLivestreamForChannel . claimUri ] : [ ]
2021-12-16 22:59:13 +01:00
}
2022-01-11 17:46:13 +01:00
showHideSetting = { false }
2021-12-16 22:59:13 +01:00
/ >
) }
2021-03-19 21:14:31 +01:00
2019-08-29 03:39:21 +02:00
{ ! fetching && channelIsBlackListed && (
< section className = "card card--section" >
< p >
{ _ _ (
2021-10-21 22:21:51 +02:00
'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications. Content may also be blocked due to DMCA Red Flag rules which are obvious copyright violations we come across, are discussed in public channels, or reported to us.'
2019-08-29 03:39:21 +02:00
) }
< / p >
2020-05-01 19:55:42 +02:00
< div className = "section__actions" >
2021-11-30 07:11:46 +01:00
< Button button = "link" href = "https://odysee.com/@OdyseeHelp:b/copyright:f" label = { _ _ ( 'Read More' ) } / >
2019-08-29 03:39:21 +02:00
< / div >
< / section >
) }
2019-07-08 22:54:58 +02:00
{ ! fetching && channelIsBlocked && (
< div className = "card--section" >
2019-08-02 17:11:31 +02:00
< h2 className = "help" > { _ _ ( 'You have blocked this channel content.' ) } < / h2 >
2019-07-08 22:54:58 +02:00
< / div >
) }
2019-05-07 04:35:04 +02:00
2020-02-28 15:40:18 +01:00
{ ! channelIsMine && claimsInChannel > 0 && < HiddenNsfwClaims uri = { uri } / > }
2019-10-27 15:41:43 +01:00
2022-02-23 14:23:42 +01:00
{ ! fetching && (
2022-07-05 19:20:10 +02:00
< ClaimSearchFilterContext.Provider value = { claimSearchFilterCtx } >
< ClaimListDiscover
ignoreSearchInLanguage
hasSource
defaultFreshness = { CS . FRESH _ALL }
showHiddenByUser = { viewHiddenChannels }
hideRepostsOverride = { hideReposts }
fetchViewCount
hideFilters = { ! showFilters }
hideAdvancedFilter = { ! showFilters }
tileLayout = { tileLayout }
uris = { isSearching ? [ ] : null }
streamType = { SIMPLE _SITE ? CS . CONTENT _ALL : undefined }
channelIds = { [ claimId ] }
claimType = { claimType }
feeAmount = { CS . FEE _AMOUNT _ANY }
defaultOrderBy = { CS . ORDER _BY _NEW }
pageSize = { dynamicPageSize }
infiniteScroll = { defaultInfiniteScroll }
injectedItem = {
! hasPremiumPlus && {
node : ( index , lastVisibleIndex , pageSize ) => {
if ( pageSize && index < pageSize ) {
return index === lastVisibleIndex ? < Ads type = "video" tileLayout = { tileLayout } small / > : null ;
} else {
return index % ( pageSize * 2 ) === 0 ? < Ads type = "video" tileLayout = { tileLayout } small / > : null ;
}
} ,
}
2022-05-18 20:51:15 +02:00
}
2022-07-05 19:20:10 +02:00
meta = {
showFilters && (
< Form onSubmit = { ( ) => { } } className = "wunderbar--inline" >
< Icon icon = { ICONS . SEARCH } / >
< FormField
name = "channel_search"
className = "wunderbar__input--inline"
value = { searchQuery }
onChange = { handleInputChange }
type = "text"
placeholder = { _ _ ( 'Search' ) }
/ >
< / Form >
)
}
subSection = {
< SearchResults
searchQuery = { searchQuery }
claimId = { claimId }
showMature = { showMature }
tileLayout = { tileLayout }
onResults = { ( results ) => setIsSearching ( results !== null ) }
doResolveUris = { doResolveUris }
/ >
}
isChannel
channelIsMine = { channelIsMine }
empty = { isSearching ? ' ' : empty }
/ >
< / ClaimSearchFilterContext.Provider >
2022-02-23 14:23:42 +01:00
) }
2019-05-07 04:35:04 +02:00
< / Fragment >
) ;
}
2020-06-18 17:10:46 +02:00
export default ChannelContent ;