Skip to content

Commit d8e23c8

Browse files
committed
Deduplication
1 parent 41544d4 commit d8e23c8

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

frontend/src/lib/components/mods-list/ModsList.svelte

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@
163163
}
164164
}
165165
166+
$: userHasSearchText = $search != '';
167+
$: userHasSearchFilters = $filter != filterOptions[0];
168+
169+
const removeSearchText = () => {
170+
$search = '';
171+
};
172+
const removeSearchFilters = () => {
173+
$filter = filterOptions[0];
174+
};
175+
166176
export let hideMods: boolean = false;
167177
</script>
168178

@@ -184,44 +194,33 @@
184194
{#if displayMods.length === 0 && !fetchingMods && !filteringMods && $hasFetchedMods}
185195
<div class="flex flex-col h-full items-center justify-center">
186196
{#if mods.length !== 0}
187-
{#if $filter != filterOptions[0]}
188-
{#if $search != ''}
189-
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods matching your search" keyName="mods-list.no-mods-filtered"/></p>
197+
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods matching your search" keyName="mods-list.no-mods-filtered"/></p>
198+
{#if userHasSearchFilters}
199+
{#if userHasSearchText}
190200
<button
191201
class="btn variant-filled-primary mt-4"
192-
on:click={() => {
193-
$filter = filterOptions[0];
194-
}}
202+
on:click={removeSearchFilters}
195203
>
196204
<T defaultValue="Remove search filters" keyName="mods-list.remove-search-filters"/>
197205
</button>
198206
<button
199207
class="btn variant-filled-primary mt-4"
200-
on:click={() => {
201-
$search = '';
202-
}}
208+
on:click={removeSearchText}
203209
>
204210
<T defaultValue="Remove search text" keyName="mods-list.remove-search-text"/>
205211
</button>
206212
{:else}
207-
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods matching your search" keyName="mods-list.no-mods-filtered"/></p>
208213
<button
209214
class="btn variant-filled-primary mt-4"
210-
on:click={() => {
211-
$filter = filterOptions[0];
212-
}}
215+
on:click={removeSearchFilters}
213216
>
214217
<T defaultValue="Show all" keyName="mods-list.show-all"/>
215218
</button>
216219
{/if}
217220
{:else}
218-
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods matching your search" keyName="mods-list.no-mods-filtered"/></p>
219221
<button
220222
class="btn variant-filled-primary mt-4"
221-
on:click={() => {
222-
$search = '';
223-
$filter = filterOptions[0];
224-
}}
223+
on:click={removeSearchText}
225224
>
226225
<T defaultValue="Show all" keyName="mods-list.show-all"/>
227226
</button>

0 commit comments

Comments
 (0)