Skip to content

Commit 8ae6980

Browse files
feat: Filter NSFW mods by default (#964)
Add an option to filter out NSFW mods from Thunderstore and filter them out by default.
1 parent fb2bb02 commit 8ae6980

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src-vue/src/plugins/modules/search.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const searchModule = {
99
// Selected mod categories
1010
selectedCategories: [],
1111
showDeprecatedMods: false,
12+
showNsfwMods: false,
1213
sortValue: {label: '', value: ''}
1314
}),
1415
getters: {

src-vue/src/views/SettingsView.vue

+16
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@
112112
</el-button>
113113
</div>
114114

115+
<div class="fc_parameter__panel">
116+
<h3>{{ $t('settings.show_nsfw_mods') }}</h3>
117+
<span>
118+
{{ $t('settings.show_nsfw_mods') }}
119+
<el-switch v-model="showNsfwMods"></el-switch>
120+
</span>
121+
</div>
122+
115123
<!-- About section -->
116124
<div class="fc_parameter__panel">
117125
<h3>{{ $t('settings.about') }}</h3>
@@ -157,6 +165,14 @@ export default defineComponent({
157165
}
158166
},
159167
computed: {
168+
showNsfwMods: {
169+
get(): boolean {
170+
return this.$store.state.search.showNsfwMods;
171+
},
172+
set(value: boolean) {
173+
this.$store.state.search.showNsfwMods = value;
174+
}
175+
},
160176
showDeprecatedMods: {
161177
get(): boolean {
162178
return this.$store.state.search.showDeprecatedMods;

src-vue/src/views/mods/ThunderstoreModsView.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export default defineComponent({
6666
showDeprecatedMods(): boolean {
6767
return this.$store.state.search.showDeprecatedMods;
6868
},
69+
showNsfwMods(): boolean {
70+
return this.$store.state.search.showNsfwMods;
71+
},
6972
searchValue(): string {
7073
return this.$store.getters.searchWords;
7174
},
@@ -95,22 +98,25 @@ export default defineComponent({
9598
// Filter out deprecated mods
9699
const showDeprecated = !mod.is_deprecated || this.showDeprecatedMods;
97100
101+
// Filter out NSFW mods
102+
const showNsfw = !mod.has_nsfw_content || this.showNsfwMods;
103+
98104
// Filter with categories (only if some categories are selected)
99105
const categoriesMatch: boolean = this.selectedCategories.length === 0
100106
|| mod.categories
101107
.filter((category: string) => this.selectedCategories.includes(category))
102108
.length === this.selectedCategories.length;
103109
104-
return inputMatches && categoriesMatch && showDeprecated;
110+
return inputMatches && categoriesMatch && showDeprecated && showNsfw;
105111
});
106112
},
107113
modsList(): ThunderstoreMod[] {
108114
// Use filtered mods if user is searching, vanilla list otherwise.
109115
const mods: ThunderstoreMod[] = this.searchValue.length !== 0 || this.selectedCategories.length !== 0
110116
? this.filteredMods
111-
: this.showDeprecatedMods
112-
? this.mods
113-
: this.mods.filter(mod => !mod.is_deprecated);
117+
: this.mods
118+
.filter(mod => this.showDeprecatedMods || !mod.is_deprecated)
119+
.filter(mod => this.showNsfwMods || !mod.has_nsfw_content);
114120
115121
// Sort mods regarding user selected algorithm.
116122
let compare: (a: ThunderstoreMod, b: ThunderstoreMod) => number;

0 commit comments

Comments
 (0)