From 1d628e5722672e6b1a3af493a953ce8dea05c301 Mon Sep 17 00:00:00 2001 From: artie Date: Tue, 11 Feb 2025 21:27:33 +0100 Subject: [PATCH] dont include language when no text was detected --- src/commands/ocr/ocr.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/commands/ocr/ocr.ts b/src/commands/ocr/ocr.ts index c316f3c..e4e253b 100644 --- a/src/commands/ocr/ocr.ts +++ b/src/commands/ocr/ocr.ts @@ -27,7 +27,7 @@ export function buildOcrPayload( try { return ( new Intl.DisplayNames(["en"], { type: "language" }).of(language) ?? - "unknown" + "Unknown" ); } catch { return "Unknown"; @@ -54,12 +54,15 @@ export function buildOcrPayload( { description: text, color: model === "yandex" ? 0xffdb4d : 0x4285f4, - fields: [ - { - name: "Detected language", - value: languageName, - }, - ], + fields: + text !== "No text detected" + ? [ + { + name: "Detected language", + value: languageName, + }, + ] + : [], ...(imageUrl ? { image: { url: imageUrl } } : {}), author: { name: capitalize(model),