Add option to show/hide NSFW content

This commit is contained in:
Alex Liebowitz 2016-08-22 15:19:04 -04:00
parent 0472ea5d9d
commit 8378a7a387
3 changed files with 18 additions and 4 deletions

View file

@ -5,7 +5,9 @@ var lbry = {
colors: { colors: {
primary: '#155B4A' primary: '#155B4A'
}, },
defaultClientSettings: {} defaultClientSettings: {
showNsfw: false,
}
}; };
lbry.jsonrpc_call = function (connectionString, method, params, callback, errorCallback, connectFailedCallback) { lbry.jsonrpc_call = function (connectionString, method, params, callback, errorCallback, connectFailedCallback) {

View file

@ -34,9 +34,10 @@ var SearchNoResults = React.createClass({
var SearchResults = React.createClass({ var SearchResults = React.createClass({
render: function() { render: function() {
var showNsfw = lbry.getClientSetting('showNsfw');
var rows = []; var rows = [];
this.props.results.forEach(function(result) { this.props.results.forEach(function(result) {
if (!result.value.nsfw) { if (showNsfw || !result.value.nsfw) {
rows.push( rows.push(
<SearchResultRow key={result.name} name={result.name} title={result.value.title} imgUrl={result.value.thumbnail} <SearchResultRow key={result.name} name={result.name} title={result.value.title} imgUrl={result.value.thumbnail}
description={result.value.description} cost={result.cost} /> description={result.value.description} cost={result.cost} />
@ -157,10 +158,10 @@ var FeaturedContentItem = React.createClass({
return null; return null;
} }
//@TODO: Make this check the "show NSFW" setting once it's implemented var blur = !lbry.getClientSetting('showNsfw') && this.state.metadata.nsfw;
return (<div style={featuredContentItemContainerStyle} onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}> return (<div style={featuredContentItemContainerStyle} onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
<div className={this.state.metadata.nsfw ? 'blur' : ''}> <div className={blur ? 'blur' : ''}>
<SearchResultRow name={this.props.name} title={this.state.title} imgUrl={this.state.metadata.thumbnail} <SearchResultRow name={this.props.name} title={this.state.title} imgUrl={this.state.metadata.thumbnail}
description={this.state.metadata.description} cost={this.state.amount} description={this.state.metadata.description} cost={this.state.amount}
available={this.state.available} /> available={this.state.available} />

View file

@ -14,6 +14,7 @@ var settingsRadioOptionStyles = {
}; };
var SettingsPage = React.createClass({ var SettingsPage = React.createClass({
_initClientSettings: null,
onRunOnStartChange: function (event) { onRunOnStartChange: function (event) {
lbry.setDaemonSetting('run_on_startup', event.target.checked); lbry.setDaemonSetting('run_on_startup', event.target.checked);
}, },
@ -52,6 +53,7 @@ var SettingsPage = React.createClass({
}, },
componentDidMount: function() { componentDidMount: function() {
document.title = "Settings"; document.title = "Settings";
this._initClientSettings = lbry.getClientSettings();
}, },
componentWillMount: function() { componentWillMount: function() {
lbry.getDaemonSettings(function(settings) { lbry.getDaemonSettings(function(settings) {
@ -62,6 +64,9 @@ var SettingsPage = React.createClass({
}); });
}.bind(this)); }.bind(this));
}, },
onShowNsfwChange: function(event) {
lbry.setClientSetting('showNsfw', event.target.checked);
},
render: function() { render: function() {
if (!this.state.initDaemonSettings) { if (!this.state.initDaemonSettings) {
return null; return null;
@ -103,6 +108,12 @@ var SettingsPage = React.createClass({
</label> </label>
</div> </div>
</section> </section>
<section className="card">
<h3>Content</h3>
<label style={settingsCheckBoxOptionStyles}>
<input type="checkbox" onChange={this.onShowNsfwChange} defaultChecked={this._initClientSettings.showNsfw} /> Include Not Safe For Work content in search results and Commmunity Content
</label>
</section>
<section className="card"> <section className="card">
<h3>Share Diagnostic Data</h3> <h3>Share Diagnostic Data</h3>
<label style={settingsCheckBoxOptionStyles}> <label style={settingsCheckBoxOptionStyles}>