aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/views
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-05-15 17:50:39 +0200
committerGitHub <noreply@github.com>2023-05-15 17:50:39 +0200
commit5edffe63d3b6f503ad29da08f281ea88682f5f90 (patch)
treed11d54223f2e2a0fefcf53f9506cf3aa0edbfe30 /src-vue/src/views
parent002d967aac31a7c7b883cc6f2003e2db7afa6247 (diff)
downloadFlightCore-5edffe63d3b6f503ad29da08f281ea88682f5f90.tar.gz
FlightCore-5edffe63d3b6f503ad29da08f281ea88682f5f90.zip
feat: Make search fuzzy (#342)
* feat: Enable fuzzy search for Thunderstore mods * feat: Enable fuzzy search for pull requests * refactor: Move filter into own util file * docs: Add comment explaining function in detail
Diffstat (limited to 'src-vue/src/views')
-rw-r--r--src-vue/src/views/mods/ThunderstoreModsView.vue9
1 files changed, 6 insertions, 3 deletions
diff --git a/src-vue/src/views/mods/ThunderstoreModsView.vue b/src-vue/src/views/mods/ThunderstoreModsView.vue
index 410af5f3..58a00367 100644
--- a/src-vue/src/views/mods/ThunderstoreModsView.vue
+++ b/src-vue/src/views/mods/ThunderstoreModsView.vue
@@ -51,6 +51,7 @@ import ThunderstoreModCard from "../../components/ThunderstoreModCard.vue";
import { ElScrollbar, ScrollbarInstance } from "element-plus";
import { SortOptions } from "../../utils/SortOptions.d";
import { ThunderstoreModVersion } from "../../../../src-tauri/bindings/ThunderstoreModVersion";
+import { fuzzy_filter } from "../../utils/filter";
export default defineComponent({
name: "ThunderstoreModsView",
@@ -79,9 +80,11 @@ export default defineComponent({
return this.mods.filter((mod: ThunderstoreMod) => {
// Filter with search words (only if search field isn't empty)
const inputMatches: boolean = this.searchValue.length === 0
- || (mod.name.toLowerCase().includes(this.searchValue)
- || mod.owner.toLowerCase().includes(this.searchValue)
- || mod.versions[0].description.toLowerCase().includes(this.searchValue));
+ || (
+ fuzzy_filter(mod.name, this.searchValue) ||
+ fuzzy_filter(mod.owner, this.searchValue) ||
+ mod.versions[0].description.toLowerCase().includes(this.searchValue)
+ );
// Filter with categories (only if some categories are selected)
const categoriesMatch: boolean = this.selectedCategories.length === 0