<% if (ob.errors.showNsfw) print(ob.formErrorTmpl({ errors: ob.errors.showNsfw })) %>
diff --git a/js/templates/search/Search.html b/js/templates/search/Search.html
index 004ab0c74..730a59a1b 100644
--- a/js/templates/search/Search.html
+++ b/js/templates/search/Search.html
@@ -87,14 +87,10 @@
<%= val.label %>
<% _.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(``);
- print(``);
+ print(``);
+ print(``);
}); %>
<% } %>
diff --git a/js/views/search/Search.js b/js/views/search/Search.js
index f5de0018d..d9a6c1536 100644
--- a/js/views/search/Search.js
+++ b/js/views/search/Search.js
@@ -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);
}
@@ -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);
}