Live wall filter: preset tags match word starts; keep typed trailing space (#235)
- Storm/Traffic preset tag terms now match at the start of a word, so
"tree" no longer pulls "street-racing"/"street-fight" into Storm mode.
- FilterBar search compared the trimmed hash q against the untrimmed
typed text, so pausing after "main " reset the box to "main" and the
next word ran on ("mainst"). Compare trimmed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f479578942
commit
2aaf474828
@@ -53,7 +53,9 @@ export function FilterBar({
|
||||
const [q, setQ] = useState(filter.q);
|
||||
const committed = useRef(filter.q);
|
||||
useEffect(() => {
|
||||
if (filter.q !== committed.current) { committed.current = filter.q; setQ(filter.q); }
|
||||
// Compare trimmed: the hash stores q trimmed, so a just-typed trailing
|
||||
// space ("main ") must not read as an outside change and get eaten.
|
||||
if (filter.q !== committed.current.trim()) { committed.current = filter.q; setQ(filter.q); }
|
||||
}, [filter.q]);
|
||||
const filterRef = useRef(filter);
|
||||
filterRef.current = filter;
|
||||
|
||||
@@ -120,6 +120,13 @@ const TRAFFIC_TAGS = ["mva", "mvc", "crash", "collision", "accident", "rollover"
|
||||
const tagHit = (tags: string[] | undefined, terms: readonly string[]) =>
|
||||
(tags ?? []).some((t) => { const l = t.toLowerCase(); return terms.some((term) => l.includes(term)); });
|
||||
|
||||
/** Preset tag terms match at the start of a word ("downed-tree", "trees"), so
|
||||
* "tree" does not pull in "street-racing" or "street-fight". */
|
||||
const wordStart = (terms: readonly string[]) => new RegExp(`(?:^|[^a-z])(?:${terms.join("|")})`);
|
||||
const STORM_RE = wordStart(STORM_TAGS);
|
||||
const TRAFFIC_RE = wordStart(TRAFFIC_TAGS);
|
||||
const presetTagHit = (tags: string[] | undefined, re: RegExp) => (tags ?? []).some((t) => re.test(t.toLowerCase()));
|
||||
|
||||
const callText = (c: CallRecord) => `${c.transcript_corrected || c.transcript || ""} ${c.location ?? ""}`;
|
||||
|
||||
interface MatchCtx {
|
||||
@@ -137,8 +144,8 @@ function presetMatch(p: PresetKey, inc: IncidentRecord, ctx: MatchCtx): boolean
|
||||
return (inc.talkgroup_ids ?? []).some((t) => ctx.fireTgs.has(String(t)))
|
||||
|| (ctx.calls.get(inc.incident_id) ?? []).some((c) => FIRE_CHANNEL.test(c.talkgroup_name ?? ""));
|
||||
}
|
||||
if (p === "storm") return tagHit(inc.tags, STORM_TAGS);
|
||||
return inc.type === "accident" || tagHit(inc.tags, TRAFFIC_TAGS);
|
||||
if (p === "storm") return presetTagHit(inc.tags, STORM_RE);
|
||||
return inc.type === "accident" || presetTagHit(inc.tags, TRAFFIC_RE);
|
||||
}
|
||||
|
||||
function lastActivity(inc: IncidentRecord): number {
|
||||
|
||||
Reference in New Issue
Block a user