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 ,
autoplay : boolean ,
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 ,
autoplay ,
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 (
< Card
2021-08-08 10:13:35 +02:00
id = { SETTINGS _GRP . CONTENT }
2021-08-06 04:41:37 +02:00
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-07 14:50:24 +02:00
< SettingsRow title = { _ _ ( 'Publish confirmation' ) } subtitle = { _ _ ( 'Skip preview and confirmation' ) } >
< FormField
type = "checkbox"
name = "sync_toggle"
label = { _ _ ( '' ) }
checked = { ! enablePublishPreview }
onChange = { ( ) => setClientSetting ( SETTINGS . ENABLE _PUBLISH _PREVIEW , ! enablePublishPreview ) }
/ >
< / 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-07 14:40:17 +02:00
< SettingsRow title = { _ _ ( 'Purchase and tip confirmations' ) } useVerticalSeparator >
< FormField
type = "radio"
name = "confirm_all_purchases"
checked = { ! instantPurchaseEnabled }
label = { _ _ ( 'Always confirm before purchasing content or tipping' ) }
onChange = { ( ) => setClientSetting ( SETTINGS . INSTANT _PURCHASE _ENABLED , false ) }
/ >
< FormField
type = "radio"
name = "instant_purchases"
checked = { instantPurchaseEnabled }
label = { _ _ ( 'Only confirm purchases or tips over a certain amount' ) }
helper = { _ _ ( HELP _ONLY _CONFIRM _OVER _AMOUNT ) }
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
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.' ;
2021-08-07 14:40:17 +02:00
const HELP _ONLY _CONFIRM _OVER _AMOUNT = '' ; // feel redundant. Disable for now.
// const HELP_ONLY_CONFIRM_OVER_AMOUNT = "When this option is chosen, LBRY won't ask you to confirm purchases or tips below your chosen amount.";