From 8378a7a387563318674c30ac00410107e7e81c1d Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Mon, 22 Aug 2016 15:19:04 -0400 Subject: [PATCH] Add option to show/hide NSFW content --- js/lbry.js | 4 +++- js/page/discover.js | 7 ++++--- js/page/settings.js | 11 +++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/js/lbry.js b/js/lbry.js index cb8a6dc02..00cbbe626 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -5,7 +5,9 @@ var lbry = { colors: { primary: '#155B4A' }, - defaultClientSettings: {} + defaultClientSettings: { + showNsfw: false, + } }; lbry.jsonrpc_call = function (connectionString, method, params, callback, errorCallback, connectFailedCallback) { diff --git a/js/page/discover.js b/js/page/discover.js index ba201dd70..14a085617 100644 --- a/js/page/discover.js +++ b/js/page/discover.js @@ -34,9 +34,10 @@ var SearchNoResults = React.createClass({ var SearchResults = React.createClass({ render: function() { + var showNsfw = lbry.getClientSetting('showNsfw'); var rows = []; this.props.results.forEach(function(result) { - if (!result.value.nsfw) { + if (showNsfw || !result.value.nsfw) { rows.push( @@ -157,10 +158,10 @@ var FeaturedContentItem = React.createClass({ return null; } - //@TODO: Make this check the "show NSFW" setting once it's implemented + var blur = !lbry.getClientSetting('showNsfw') && this.state.metadata.nsfw; return (
-
+
diff --git a/js/page/settings.js b/js/page/settings.js index c7248d190..fef48c711 100644 --- a/js/page/settings.js +++ b/js/page/settings.js @@ -14,6 +14,7 @@ var settingsRadioOptionStyles = { }; var SettingsPage = React.createClass({ + _initClientSettings: null, onRunOnStartChange: function (event) { lbry.setDaemonSetting('run_on_startup', event.target.checked); }, @@ -52,6 +53,7 @@ var SettingsPage = React.createClass({ }, componentDidMount: function() { document.title = "Settings"; + this._initClientSettings = lbry.getClientSettings(); }, componentWillMount: function() { lbry.getDaemonSettings(function(settings) { @@ -62,6 +64,9 @@ var SettingsPage = React.createClass({ }); }.bind(this)); }, + onShowNsfwChange: function(event) { + lbry.setClientSetting('showNsfw', event.target.checked); + }, render: function() { if (!this.state.initDaemonSettings) { return null; @@ -103,6 +108,12 @@ var SettingsPage = React.createClass({
+
+

Content

+ +

Share Diagnostic Data