feat(exercises): add multi-token, accent-insensitive and multilingual exercise search

This commit is contained in:
wagenheimer committed 2026-08-24 14:32:00 -03:00
1 parent f8024d344d
commit 4df4406139
4 files changed
+135 -6

No files matched your search

+2 -3
View File
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react'
import { useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf } from './lib/exercises.js'
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, matchExercise } from './lib/exercises.js'
import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, uid, exCount, DAYN, MONTHS_LONG, ACCENTS } from './lib/format.js'
import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, isBw, isPerSide, sideReps, workSetsDone } from './lib/history.js'
import { beep, vibrate } from './lib/sound.js'
@@ -422,11 +422,10 @@ function ExercisePicker({ onPick, close }) {
const [bp, setBp] = useState('') // '' = all, '★' = chosen, else a body part
const [eq, setEq] = useState('') // '' = any equipment
const [shown, setShown] = useState(50)
const ql = q.toLowerCase().trim()
const all = allExercises(st)
let base = all.filter(e =>
(bp === '★' ? usage[e.id] : (!bp || e.bp === bp)) &&
(!ql || e.n.toLowerCase().includes(ql) || e.tg.includes(ql) || e.eq.includes(ql) || (e.desc || '').toLowerCase().includes(ql)))
matchExercise(e, q))
if (bp === '★') base = [...base].sort((a, b) => (usage[b.id] - usage[a.id]) || (a.n < b.n ? -1 : 1))
const eqOpts = equipmentOf(base)
// Drop the equipment filter if the search narrowed it away, so you never hit a dead end.