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

Commit

Permalink
Merge pull request #890 from OpenBazaar/nfswSearch
Browse files Browse the repository at this point in the history
Handle NSFW in Search
  • Loading branch information
rmisio authored Sep 22, 2017
2 parents 3509e04 + 5a6f8b4 commit 61e3494
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion js/models/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class extends BaseModel {
return {
paymentDataInQR: false,
showNotifications: true,
showNsfw: true,
showNsfw: false,
localCurrency: 'USD',
country: 'UNITED_STATES',
language: 'en-US',
Expand Down
4 changes: 2 additions & 2 deletions js/templates/modals/settings/general.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ <h2 class="h3 clrT"><%= ob.polyT('settings.generalTab.sectionName') %></h2>
</div>
</div>
</div>
<div class="flexRow gutterH TODO">
<div class="flexRow gutterH">
<div class="col3">
<label class="required"><%= ob.polyT('settings.viewNsfwContent') %></label>
<label><%= ob.polyT('settings.viewNsfwContent') %></label>
</div>
<div class="col9">
<% if (ob.errors.showNsfw) print(ob.formErrorTmpl({ errors: ob.errors.showNsfw })) %>
Expand Down
10 changes: 3 additions & 7 deletions js/templates/search/Search.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ <h4 class="rowSm"><%= val.label %></h4>
<div class="flexCol">
<% _.each(val.options, function(option, index) {
let checked = '';
if (ob.filterVals.hasOwnProperty(key)) {
checked = option.value === ob.filterVals[key] ? 'checked' : '';
} else {
checked = option.default ? 'checked' : '';
}
checked = option.checked ? 'checked' : '';
var parsedLabel = ob.parseEmojis(option.label);
print(`<input type="checkbox" ${checked} value="${option.value}" id="${key + index}" name="${key}">`);
print(`<label for="${key + index}">${parsedLabel}</label>`);
print(`<input type="checkbox" ${checked} id="${option.name}" name="${option.name}">`);
print(`<label for="${option.name}">${parsedLabel}</label>`);
}); %>
</div>
<% } %>
Expand Down
8 changes: 7 additions & 1 deletion js/views/search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export default class extends baseVw {
this.sortBySelected = options.sortBySelected || params.sortBy || '';
// all parameters not specified above are assumed to be filters
this.filters = _.omit(params, ['q', 'p', 'ps', 'sortBy', 'providerQ', 'network']);
// if the nsfw filter is not set, use the value from settings
this.filters.nsfw = this.filters.nsfw || String(app.settings.get('showNsfw'));

this.processTerm(this.term);
}
Expand Down Expand Up @@ -367,7 +369,11 @@ export default class extends baseVw {

changeFilter(e) {
const targ = $(e.target);
this.filters[targ.prop('name')] = targ.val();
if (targ[0].type === 'checkbox') {
this.filters[targ.prop('name')] = String(targ[0].checked);
} else {
this.filters[targ.prop('name')] = targ.val();
}
this.serverPage = 0;
this.processTerm(this.term);
}
Expand Down

0 comments on commit 61e3494

Please sign in to comment.