From 414f6df1049005e82a70935f9b543f5a5b821716 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 19 Sep 2023 17:14:01 -0700 Subject: [PATCH] simplify --- packages/backend/src/models/repositories/note.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 6e5ef2f718..b553c71c06 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -204,14 +204,7 @@ export const NoteRepository = db.getRepository(Note).extend({ host, ); - let lang; - try { - lang = (detectLanguage_((note.text || "") + (note.cw || ""))) - .languages[0].code; - } catch (e) { - lang = - detect((note.text || "") + (note.cw || ""))?.[0]?.lang || "unknown"; - } + const lang = detectLanguage_(`${note.cw ?? ''}\n${note.text ?? ''}`) ?? "unknown" const reactionEmoji = await populateEmojis(reactionEmojiNames, host); const packed: Packed<"Note"> = await awaitAll({ id: note.id,