2021-08-06 04:41:37 +02:00
// @flow
2021-08-06 09:56:48 +02:00
import * as ICONS from 'constants/icons' ;
import * as PAGES from 'constants/pages' ;
2021-08-06 04:41:37 +02:00
import React from 'react' ;
import { SETTINGS } from 'lbry-redux' ;
import { Lbryio } from 'lbryinc' ;
import { SIMPLE _SITE } from 'config' ;
import * as MODALS from 'constants/modal_types' ;
2021-08-06 09:56:48 +02:00
import Button from 'component/button' ;
2021-08-06 04:41:37 +02:00
import Card from 'component/common/card' ;
import { FormField } from 'component/common/form' ;
import MaxPurchasePrice from 'component/maxPurchasePrice' ;
import SettingsRow from 'component/settingsRow' ;
type Props = {
isAuthenticated : boolean ,
floatingPlayer : boolean ,
autoplay : boolean ,
hideReposts : ? boolean ,
showNsfw : boolean ,
2021-08-06 09:56:48 +02:00
myChannelUrls : ? Array < string > ,
2021-08-06 04:41:37 +02:00
setClientSetting : ( string , boolean | string | number ) => void ,
clearPlayingUri : ( ) => void ,
openModal : ( string ) => void ,
} ;
export default function SettingContent ( props : Props ) {
const {
isAuthenticated ,
floatingPlayer ,
autoplay ,
hideReposts ,
showNsfw ,
2021-08-06 09:56:48 +02:00
myChannelUrls ,
2021-08-06 04:41:37 +02:00
setClientSetting ,
clearPlayingUri ,
openModal ,
} = props ;
return (
< Card
title = { _ _ ( 'Content settings' ) }
subtitle = ""
isBodyList
body = {
< >
< SettingsRow title = { _ _ ( 'Floating video player' ) } subtitle = { _ _ ( HELP _FLOATING _PLAYER ) } >
< FormField
type = "checkbox"
name = "floating_player"
onChange = { ( ) => {
setClientSetting ( SETTINGS . FLOATING _PLAYER , ! floatingPlayer ) ;
clearPlayingUri ( ) ;
} }
checked = { floatingPlayer }
/ >
< / SettingsRow >
< SettingsRow title = { _ _ ( 'Autoplay media files' ) } subtitle = { _ _ ( HELP _AUTOPLAY ) } >
< FormField
type = "checkbox"
name = "autoplay"
onChange = { ( ) => setClientSetting ( SETTINGS . AUTOPLAY , ! autoplay ) }
checked = { autoplay }
/ >
< / SettingsRow >
{ ! SIMPLE _SITE && (
< >
< SettingsRow title = { _ _ ( 'Hide reposts' ) } subtitle = { _ _ ( HELP _HIDE _REPOSTS ) } >
< FormField
type = "checkbox"
name = "hide_reposts"
onChange = { ( e ) => {
if ( isAuthenticated ) {
let param = e . target . checked ? { add : 'noreposts' } : { remove : 'noreposts' } ;
Lbryio . call ( 'user_tag' , 'edit' , param ) ;
}
setClientSetting ( SETTINGS . HIDE _REPOSTS , ! hideReposts ) ;
} }
/ >
< / SettingsRow >
{ / *
< SettingsRow title = { _ _ ( 'Show anonymous content' ) } subtitle = { _ _ ( 'Anonymous content is published without a channel.' ) } >
< FormField
type = "checkbox"
name = "show_anonymous"
onChange = { ( ) => setClientSetting ( SETTINGS . SHOW _ANONYMOUS , ! showAnonymous ) }
checked = { showAnonymous }
/ >
< / SettingsRow >
* / }
< SettingsRow title = { _ _ ( 'Show mature content' ) } subtitle = { _ _ ( HELP _SHOW _MATURE ) } >
< FormField
type = "checkbox"
name = "show_nsfw"
checked = { showNsfw }
onChange = { ( ) =>
! IS _WEB || showNsfw
? setClientSetting ( SETTINGS . SHOW _MATURE , ! showNsfw )
: openModal ( MODALS . CONFIRM _AGE )
}
/ >
< / SettingsRow >
< / >
) }
2021-08-06 07:58:34 +02:00
2021-08-06 09:56:48 +02:00
{ ( isAuthenticated || ! IS _WEB ) && (
< >
< SettingsRow title = { _ _ ( 'Notifications' ) } >
< Button
button = "secondary"
label = { _ _ ( 'Manage' ) }
icon = { ICONS . SETTINGS }
navigate = { ` / $ / ${ PAGES . SETTINGS _NOTIFICATIONS } ` }
/ >
< / SettingsRow >
< SettingsRow title = { _ _ ( 'Blocked and muted channels' ) } >
< Button
button = "secondary"
label = { _ _ ( 'Manage' ) }
icon = { ICONS . SETTINGS }
navigate = { ` / $ / ${ PAGES . SETTINGS _BLOCKED _MUTED } ` }
/ >
< / SettingsRow >
{ myChannelUrls && myChannelUrls . length > 0 && (
< SettingsRow title = { _ _ ( 'Creator settings' ) } >
< Button
button = "secondary"
label = { _ _ ( 'Manage' ) }
icon = { ICONS . SETTINGS }
navigate = { ` / $ / ${ PAGES . SETTINGS _CREATOR } ` }
/ >
< / SettingsRow >
) }
< / >
) }
2021-08-06 07:58:34 +02:00
{ /* @if TARGET='app' */ }
< SettingsRow title = { _ _ ( 'Max purchase price' ) } subtitle = { _ _ ( HELP _MAX _PURCHASE _PRICE ) } useVerticalSeparator >
< MaxPurchasePrice / >
< / SettingsRow >
{ /* @endif */ }
2021-08-06 04:41:37 +02:00
< / >
}
/ >
) ;
}
2021-08-06 09:56:48 +02:00
const HELP _FLOATING _PLAYER = 'Keep content playing in the corner when navigating to a different page.' ;
const HELP _AUTOPLAY =
'Autoplay video and audio files when navigating to a file, as well as the next related item when a file finishes playing.' ;
const HELP _HIDE _REPOSTS = 'You will not see reposts by people you follow or receive email notifying about them.' ;
const HELP _SHOW _MATURE =
'Mature content may include nudity, intense sexuality, profanity, or other adult content. By displaying mature content, you are affirming you are of legal age to view mature content in your country or jurisdiction. ' ;
const HELP _MAX _PURCHASE _PRICE =
'This will prevent you from purchasing any content over a certain cost, as a safety measure.' ;