Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 61e3494

Browse files
authored
Merge pull request #890 from OpenBazaar/nfswSearch
Handle NSFW in Search
2 parents 3509e04 + 5a6f8b4 commit 61e3494

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

js/models/Settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class extends BaseModel {
99
return {
1010
paymentDataInQR: false,
1111
showNotifications: true,
12-
showNsfw: true,
12+
showNsfw: false,
1313
localCurrency: 'USD',
1414
country: 'UNITED_STATES',
1515
language: 'en-US',

js/templates/modals/settings/general.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ <h2 class="h3 clrT"><%= ob.polyT('settings.generalTab.sectionName') %></h2>
9898
</div>
9999
</div>
100100
</div>
101-
<div class="flexRow gutterH TODO">
101+
<div class="flexRow gutterH">
102102
<div class="col3">
103-
<label class="required"><%= ob.polyT('settings.viewNsfwContent') %></label>
103+
<label><%= ob.polyT('settings.viewNsfwContent') %></label>
104104
</div>
105105
<div class="col9">
106106
<% if (ob.errors.showNsfw) print(ob.formErrorTmpl({ errors: ob.errors.showNsfw })) %>

js/templates/search/Search.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,10 @@ <h4 class="rowSm"><%= val.label %></h4>
8787
<div class="flexCol">
8888
<% _.each(val.options, function(option, index) {
8989
let checked = '';
90-
if (ob.filterVals.hasOwnProperty(key)) {
91-
checked = option.value === ob.filterVals[key] ? 'checked' : '';
92-
} else {
93-
checked = option.default ? 'checked' : '';
94-
}
90+
checked = option.checked ? 'checked' : '';
9591
var parsedLabel = ob.parseEmojis(option.label);
96-
print(`<input type="checkbox" ${checked} value="${option.value}" id="${key + index}" name="${key}">`);
97-
print(`<label for="${key + index}">${parsedLabel}</label>`);
92+
print(`<input type="checkbox" ${checked} id="${option.name}" name="${option.name}">`);
93+
print(`<label for="${option.name}">${parsedLabel}</label>`);
9894
}); %>
9995
</div>
10096
<% } %>

js/views/search/Search.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default class extends baseVw {
7979
this.sortBySelected = options.sortBySelected || params.sortBy || '';
8080
// all parameters not specified above are assumed to be filters
8181
this.filters = _.omit(params, ['q', 'p', 'ps', 'sortBy', 'providerQ', 'network']);
82+
// if the nsfw filter is not set, use the value from settings
83+
this.filters.nsfw = this.filters.nsfw || String(app.settings.get('showNsfw'));
8284

8385
this.processTerm(this.term);
8486
}
@@ -367,7 +369,11 @@ export default class extends baseVw {
367369

368370
changeFilter(e) {
369371
const targ = $(e.target);
370-
this.filters[targ.prop('name')] = targ.val();
372+
if (targ[0].type === 'checkbox') {
373+
this.filters[targ.prop('name')] = String(targ[0].checked);
374+
} else {
375+
this.filters[targ.prop('name')] = targ.val();
376+
}
371377
this.serverPage = 0;
372378
this.processTerm(this.term);
373379
}

0 commit comments

Comments
 (0)