aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/components
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/components
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/components')
-rw-r--r--src-vue/src/components/PullRequestsSelector.vue13
1 files changed, 5 insertions, 8 deletions
diff --git a/src-vue/src/components/PullRequestsSelector.vue b/src-vue/src/components/PullRequestsSelector.vue
index 4bc8f9f5..fe103edc 100644
--- a/src-vue/src/components/PullRequestsSelector.vue
+++ b/src-vue/src/components/PullRequestsSelector.vue
@@ -80,6 +80,7 @@
import { defineComponent } from 'vue'
import { PullRequestType } from '../../../src-tauri/bindings/PullRequestType';
import { PullsApiResponseElement } from '../../../src-tauri/bindings/PullsApiResponseElement';
+import { fuzzy_filter } from "../utils/filter";
export default defineComponent({
name: 'PullRequestsSelector',
@@ -101,10 +102,8 @@ export default defineComponent({
}
return this.pull_requests_launcher.filter(pr =>
- // Check PR id
- pr.number.toString().indexOf(this.launcherSearch) !== -1
- // Check PR title
- || pr.title.toLowerCase().indexOf(this.launcherSearch.toLowerCase()) !== -1);
+ // Check PR id and title
+ fuzzy_filter(pr.number.toString(), this.launcherSearch) || fuzzy_filter(pr.title, this.launcherSearch));
},
filtered_mods_pull_requests(): PullsApiResponseElement[] {
if (this.modsSearch.length === 0) {
@@ -112,10 +111,8 @@ export default defineComponent({
}
return this.pull_requests_mods.filter(pr =>
- // Check PR id
- pr.number.toString().indexOf(this.modsSearch) !== -1
- // Check PR title
- || pr.title.toLowerCase().indexOf(this.modsSearch.toLowerCase()) !== -1);
+ // Check PR id and title
+ fuzzy_filter(pr.number.toString(), this.modsSearch) || fuzzy_filter(pr.title, this.modsSearch));
},
},
methods: {