From ce0740b885fc8efeaa9498932c56b9b101ab9619 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:27:19 -0500 Subject: [PATCH] TypingTweaks: Fix crashing in some languages (#2998) --- src/plugins/typingTweaks/index.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/plugins/typingTweaks/index.tsx b/src/plugins/typingTweaks/index.tsx index 4fb3c775..e2bbb4bc 100644 --- a/src/plugins/typingTweaks/index.tsx +++ b/src/plugins/typingTweaks/index.tsx @@ -129,14 +129,22 @@ export default definePlugin({ buildSeveralUsers, mutateChildren(props: any, users: User[], children: any) { - if (!Array.isArray(children)) return children; + try { + if (!Array.isArray(children)) { + return children; + } - let element = 0; + let element = 0; - return children.map(c => - c.type === "strong" - ? - : c - ); + return children.map(c => + c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c)) + ? + : c + ); + } catch (e) { + console.error(e); + } + + return children; } });