From 4bdbc7e26dcc022e11e7b75f758a41cd5710f74b Mon Sep 17 00:00:00 2001 From: javiersuweijie Date: Fri, 25 Oct 2024 15:38:21 +0800 Subject: [PATCH] fix: process email --- packages/app/src/components/entry-form.tsx | 8 ++++++++ packages/app/src/lib/regex.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/app/src/components/entry-form.tsx b/packages/app/src/components/entry-form.tsx index 0d2e9b1..2f64e12 100644 --- a/packages/app/src/components/entry-form.tsx +++ b/packages/app/src/components/entry-form.tsx @@ -312,12 +312,20 @@ export function EntryForm({ onFormSubmit, entry }: EntryFormProps) { let result; try { result = await processEmail(e, email.contents) + console.log("result", result) } catch (e) { setProcessedResult({ error: true, matches: [], message: `Failed to process email: ${e}`, }) + setIsProcessingEmail(false); + return + } + if (result && result.error) { + setProcessedResult(result) + setIsProcessingEmail(false); + return } try { const slug = "drafts/"+form.getValues("slug"); diff --git a/packages/app/src/lib/regex.ts b/packages/app/src/lib/regex.ts index 20fa78c..f5f5437 100644 --- a/packages/app/src/lib/regex.ts +++ b/packages/app/src/lib/regex.ts @@ -66,7 +66,7 @@ export function extractMatches(headerString: string, bodyString: string | undefi } export async function extractMatchesWasm(headerString: string, bodyString: string | undefined, values: Values[]) { - let ready = await wasmLoaded; + await wasmLoaded; let matches: {name: string, match: string}[] = []; for (const value of values) { if (value.location == "body" && bodyString) {