From 2652861cd73b02af87830badd5e8ee0b1fcbbe9c Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Mon, 25 Jul 2022 23:52:38 -0400 Subject: [PATCH] Don't include failed translations --- src/api.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api.ts b/src/api.ts index 94571cd..9ca46f1 100644 --- a/src/api.ts +++ b/src/api.ts @@ -123,11 +123,13 @@ const populateTweetProperties = async ( conversation.guestToken || '', language ); - apiTweet.translation = { - text: translateAPI?.translation || '', - source_lang: translateAPI?.sourceLanguage || '', - target_lang: translateAPI?.destinationLanguage || '' - }; + if (translateAPI !== null) { + apiTweet.translation = { + text: translateAPI?.translation || '', + source_lang: translateAPI?.sourceLanguage || '', + target_lang: translateAPI?.destinationLanguage || '' + }; + } } return apiTweet;