From eac8a026a61e7e147ad0bd7fddf9efc1af14a70b Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 18 May 2024 21:53:22 -0300 Subject: [PATCH] fix(PatchHelper): Make find and match more responsive --- .../VencordSettings/PatchHelperTab.tsx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/components/VencordSettings/PatchHelperTab.tsx b/src/components/VencordSettings/PatchHelperTab.tsx index 013e32d7d..e09a1dbf3 100644 --- a/src/components/VencordSettings/PatchHelperTab.tsx +++ b/src/components/VencordSettings/PatchHelperTab.tsx @@ -306,20 +306,16 @@ function PatchHelper() { }, [parsedFind, match, replacement]); function onFindChange(v: string) { - setFindError(void 0); setFind(v); - } - function onFindBlur() { try { - let parsedFind = find as string | RegExp; - if (/^\/.+?\/$/.test(find)) parsedFind = new RegExp(find.slice(1, -1)); + let parsedFind = v as string | RegExp; + if (/^\/.+?\/$/.test(v)) parsedFind = new RegExp(v.slice(1, -1)); setFindError(void 0); - setFind(find); setParsedFind(parsedFind); - if (find.length) { + if (v.length) { findCandidates({ find: parsedFind, setModule, setError: setFindError }); } } catch (e: any) { @@ -328,15 +324,11 @@ function PatchHelper() { } function onMatchChange(v: string) { - setMatchError(void 0); setMatch(v); - } - function onMatchBlur() { try { - new RegExp(match); + new RegExp(v); setMatchError(void 0); - setMatch(match); } catch (e: any) { setMatchError((e as Error).message); } @@ -357,7 +349,6 @@ function PatchHelper() { type="text" value={find} onChange={onFindChange} - onBlur={onFindBlur} error={findError} /> @@ -366,7 +357,6 @@ function PatchHelper() { type="text" value={match} onChange={onMatchChange} - onBlur={onMatchBlur} error={matchError} />