From 9c9a5fdd63290b7a9a14aa6294d33da752f3f238 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Tue, 13 Jun 2023 14:10:51 +1200 Subject: [PATCH] Trim search queries - 1.138 Closes #156 --- BestList.tsx | 2 +- PlanList.tsx | 5 ++++- SetList.tsx | 2 +- WorkoutList.tsx | 4 ++-- android/app/build.gradle | 4 ++-- package.json | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/BestList.tsx b/BestList.tsx index 6118c3e..ed54760 100644 --- a/BestList.tsx +++ b/BestList.tsx @@ -30,7 +30,7 @@ export default function BestList() { .createQueryBuilder() .select() .addSelect('MAX(weight)', 'weight') - .where('name LIKE :name', {name: `%${value}%`}) + .where('name LIKE :name', {name: `%${value.trim()}%`}) .andWhere('NOT hidden') .groupBy('name') .getMany() diff --git a/PlanList.tsx b/PlanList.tsx index 90b5546..a33f5fe 100644 --- a/PlanList.tsx +++ b/PlanList.tsx @@ -24,7 +24,10 @@ export default function PlanList() { const refresh = useCallback(async (value: string) => { planRepo .find({ - where: [{days: Like(`%${value}%`)}, {workouts: Like(`%${value}%`)}], + where: [ + {days: Like(`%${value.trim()}%`)}, + {workouts: Like(`%${value.trim()}%`)}, + ], }) .then(setPlans) }, []) diff --git a/SetList.tsx b/SetList.tsx index 8c824f6..a6017b5 100644 --- a/SetList.tsx +++ b/SetList.tsx @@ -29,7 +29,7 @@ export default function SetList() { const refresh = useCallback(async (value: string) => { const newSets = await setRepo.find({ - where: {name: Like(`%${value}%`), hidden: 0 as any}, + where: {name: Like(`%${value.trim()}%`), hidden: 0 as any}, take: limit, skip: 0, order: {created: 'DESC'}, diff --git a/WorkoutList.tsx b/WorkoutList.tsx index c068f0f..1c02d98 100644 --- a/WorkoutList.tsx +++ b/WorkoutList.tsx @@ -29,7 +29,7 @@ export default function WorkoutList() { const newWorkouts = await setRepo .createQueryBuilder() .select() - .where('name LIKE :name', {name: `%${value}%`}) + .where('name LIKE :name', {name: `%${value.trim()}%`}) .groupBy('name') .orderBy('name') .limit(limit) @@ -71,7 +71,7 @@ export default function WorkoutList() { const newWorkouts = await setRepo .createQueryBuilder() .select() - .where('name LIKE :name', {name: `%${term}%`}) + .where('name LIKE :name', {name: `%${term.trim()}%`}) .groupBy('name') .orderBy('name') .limit(limit) diff --git a/android/app/build.gradle b/android/app/build.gradle index 4a0dac2..44cd115 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -41,8 +41,8 @@ android { missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 36163 - versionName "1.137" + versionCode 36164 + versionName "1.138" buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() if (isNewArchitectureEnabled()) { diff --git a/package.json b/package.json index 4d5857a..f12a842 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "massive", - "version": "1.137", + "version": "1.138", "private": true, "license": "GPL-3.0-only", "scripts": {