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-08 10:13:35 +02:00
import { SETTINGS _GRP } from 'constants/settings' ;
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' ;
2021-08-07 14:40:17 +02:00
import { FormField , FormFieldPrice } from 'component/common/form' ;
2021-08-06 04:41:37 +02:00
import MaxPurchasePrice from 'component/maxPurchasePrice' ;
import SettingsRow from 'component/settingsRow' ;
2021-08-07 14:40:17 +02:00
type Price = {
currency : string ,
amount : number ,
} ;
2021-08-06 04:41:37 +02:00
type Props = {
2021-08-07 14:50:24 +02:00
// --- select ---
2021-08-06 04:41:37 +02:00
isAuthenticated : boolean ,
floatingPlayer : boolean ,
2021-09-02 22:05:32 +02:00
autoplayMedia : boolean ,
autoplayNext : boolean ,
2021-08-06 04:41:37 +02:00
hideReposts : ? boolean ,
showNsfw : boolean ,
2021-08-06 09:56:48 +02:00
myChannelUrls : ? Array < string > ,
2021-08-07 14:40:17 +02:00
instantPurchaseEnabled : boolean ,
instantPurchaseMax : Price ,
2021-08-07 14:50:24 +02:00
enablePublishPreview : boolean ,
// --- perform ---
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 ,
2021-09-02 22:05:32 +02:00
autoplayMedia ,
autoplayNext ,
2021-08-06 04:41:37 +02:00
hideReposts ,
showNsfw ,
2021-08-06 09:56:48 +02:00
myChannelUrls ,
2021-08-07 14:40:17 +02:00
instantPurchaseEnabled ,
instantPurchaseMax ,
2021-08-07 14:50:24 +02:00
enablePublishPreview ,
2021-08-06 04:41:37 +02:00
setClientSetting ,
clearPlayingUri ,
openModal ,
} = props ;
return (
2021-08-09 04:22:16 +02:00
< >
< div className = "card__title-section" >
< h2 className = "card__title" > { _ _ ( 'Content settings' ) } < / h2 >
< / div >
< Card
id = { SETTINGS _GRP . CONTENT }
isBodyList
body = {
< >
2021-08-19 09:10:04 +02:00
< SettingsRow title = { _ _ ( 'Floating video player' ) } subtitle = { _ _ ( HELP . FLOATING _PLAYER ) } >
2021-08-09 04:22:16 +02:00
< FormField
type = "checkbox"
name = "floating_player"
onChange = { ( ) => {
setClientSetting ( SETTINGS . FLOATING _PLAYER , ! floatingPlayer ) ;
clearPlayingUri ( ) ;
} }
checked = { floatingPlayer }
/ >
< / SettingsRow >
2021-08-06 04:41:37 +02:00
2021-09-02 22:05:32 +02:00
< SettingsRow title = { _ _ ( 'Autoplay media files' ) } subtitle = { _ _ ( HELP . AUTOPLAY _MEDIA ) } >
2021-08-09 04:22:16 +02:00
< FormField
type = "checkbox"
2021-09-02 22:05:32 +02:00
name = "autoplay media"
onChange = { ( ) => setClientSetting ( SETTINGS . AUTOPLAY _MEDIA , ! autoplayMedia ) }
checked = { autoplayMedia }
/ >
< / SettingsRow >
< SettingsRow title = { _ _ ( 'Autoplay next recommended content' ) } subtitle = { _ _ ( HELP . AUTOPLAY _NEXT ) } >
< FormField
type = "checkbox"
name = "autoplay next"
onChange = { ( ) => setClientSetting ( SETTINGS . AUTOPLAY _NEXT , ! autoplayNext ) }
checked = { autoplayNext }
2021-08-09 04:22:16 +02:00
/ >
< / SettingsRow >
2021-08-06 04:41:37 +02:00
2021-08-09 04:22:16 +02:00
{ ! SIMPLE _SITE && (
< >
2021-08-19 09:10:04 +02:00
< SettingsRow title = { _ _ ( 'Hide reposts' ) } subtitle = { _ _ ( HELP . HIDE _REPOSTS ) } >
2021-08-09 04:22:16 +02:00
< 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 >
2021-08-06 04:41:37 +02:00
2021-08-09 04:22:16 +02:00
{ / *
2021-08-06 04:41:37 +02:00
< 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 >
* / }
2021-08-19 09:10:04 +02:00
< SettingsRow title = { _ _ ( 'Show mature content' ) } subtitle = { _ _ ( HELP . SHOW _MATURE ) } >
2021-08-09 04:22:16 +02:00
< 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 09:56:48 +02:00
2021-08-09 04:22:16 +02:00
{ ( isAuthenticated || ! IS _WEB ) && (
< >
< SettingsRow title = { _ _ ( 'Notifications' ) } >
< Button
2021-08-19 16:38:15 +02:00
button = "inverse"
2021-08-09 04:22:16 +02:00
label = { _ _ ( 'Manage' ) }
2021-08-19 16:38:15 +02:00
icon = { ICONS . ARROW _RIGHT }
2021-08-09 04:22:16 +02:00
navigate = { ` / $ / ${ PAGES . SETTINGS _NOTIFICATIONS } ` }
/ >
< / SettingsRow >
2021-08-06 09:56:48 +02:00
2021-08-09 04:22:16 +02:00
< SettingsRow title = { _ _ ( 'Blocked and muted channels' ) } >
2021-08-06 09:56:48 +02:00
< Button
2021-08-19 16:38:15 +02:00
button = "inverse"
2021-08-06 09:56:48 +02:00
label = { _ _ ( 'Manage' ) }
2021-08-19 16:38:15 +02:00
icon = { ICONS . ARROW _RIGHT }
2021-08-09 04:22:16 +02:00
navigate = { ` / $ / ${ PAGES . SETTINGS _BLOCKED _MUTED } ` }
2021-08-06 09:56:48 +02:00
/ >
< / SettingsRow >
2021-08-09 04:22:16 +02:00
{ myChannelUrls && myChannelUrls . length > 0 && (
< SettingsRow title = { _ _ ( 'Creator settings' ) } >
< Button
2021-08-19 16:38:15 +02:00
button = "inverse"
2021-08-09 04:22:16 +02:00
label = { _ _ ( 'Manage' ) }
2021-08-19 16:38:15 +02:00
icon = { ICONS . ARROW _RIGHT }
2021-08-09 04:22:16 +02:00
navigate = { ` / $ / ${ PAGES . SETTINGS _CREATOR } ` }
/ >
< / SettingsRow >
) }
< / >
) }
2021-08-19 09:18:36 +02:00
< SettingsRow title = { _ _ ( 'Publish confirmation' ) } subtitle = { _ _ ( HELP . PUBLISH _PREVIEW ) } >
2021-08-09 04:22:16 +02:00
< FormField
type = "checkbox"
name = "sync_toggle"
label = { _ _ ( '' ) }
2021-08-19 09:18:36 +02:00
checked = { enablePublishPreview }
2021-08-09 04:22:16 +02:00
onChange = { ( ) => setClientSetting ( SETTINGS . ENABLE _PUBLISH _PREVIEW , ! enablePublishPreview ) }
/ >
< / SettingsRow >
2021-08-07 14:50:24 +02:00
2021-08-09 04:22:16 +02:00
{ /* @if TARGET='app' */ }
2021-08-22 09:58:56 +02:00
< SettingsRow title = { _ _ ( 'Max purchase price' ) } subtitle = { _ _ ( HELP . MAX _PURCHASE _PRICE ) } multirow >
2021-08-09 04:22:16 +02:00
< MaxPurchasePrice / >
< / SettingsRow >
{ /* @endif */ }
2021-08-07 14:40:17 +02:00
2021-08-22 09:58:56 +02:00
< SettingsRow title = { _ _ ( 'Purchase and tip confirmations' ) } multirow >
2021-08-09 04:22:16 +02:00
< FormField
type = "radio"
name = "confirm_all_purchases"
checked = { ! instantPurchaseEnabled }
label = { _ _ ( 'Always confirm before purchasing content or tipping' ) }
onChange = { ( ) => setClientSetting ( SETTINGS . INSTANT _PURCHASE _ENABLED , false ) }
2021-08-07 14:40:17 +02:00
/ >
2021-08-09 04:22:16 +02:00
< FormField
type = "radio"
name = "instant_purchases"
checked = { instantPurchaseEnabled }
label = { _ _ ( 'Only confirm purchases or tips over a certain amount' ) }
2021-08-19 09:10:04 +02:00
helper = { _ _ ( HELP . ONLY _CONFIRM _OVER _AMOUNT ) }
2021-08-09 04:22:16 +02:00
onChange = { ( ) => setClientSetting ( SETTINGS . INSTANT _PURCHASE _ENABLED , true ) }
/ >
{ instantPurchaseEnabled && (
< FormFieldPrice
name = "confirmation_price"
min = { 0.1 }
onChange = { ( newValue ) => setClientSetting ( SETTINGS . INSTANT _PURCHASE _MAX , newValue ) }
price = { instantPurchaseMax }
/ >
) }
< / SettingsRow >
< / >
}
/ >
< / >
2021-08-06 04:41:37 +02:00
) ;
}
2021-08-06 09:56:48 +02:00
2021-08-19 09:10:04 +02:00
// prettier-ignore
const HELP = {
FLOATING _PLAYER : 'Keep content playing in the corner when navigating to a different page.' ,
2021-09-02 22:05:32 +02:00
AUTOPLAY _MEDIA : 'Autoplay video and audio files when navigating to a file.' ,
AUTOPLAY _NEXT : 'Autoplay video and audio files as the next related item when a file finishes playing.' ,
2021-08-19 09:10:04 +02:00
HIDE _REPOSTS : 'You will not see reposts by people you follow or receive email notifying about them.' ,
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. ' ,
MAX _PURCHASE _PRICE : 'This will prevent you from purchasing any content over a certain cost, as a safety measure.' ,
ONLY _CONFIRM _OVER _AMOUNT : '' , // [feel redundant. Disable for now] "When this option is chosen, LBRY won't ask you to confirm purchases or tips below your chosen amount.",
2021-08-19 09:18:36 +02:00
PUBLISH _PREVIEW : 'Show preview and confirmation dialog before publishing content.' ,
2021-08-19 09:10:04 +02:00
} ;