TypingTweaks: Fix crashing in some languages (#2998)

This commit is contained in:
sadan4 2024-11-07 13:27:19 -05:00 committed by Nuckyz
parent 64c3dd1c16
commit ce0740b885
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -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"
? <TypingUser {...props} user={users[element++]} />
: c
);
return children.map(c =>
c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c))
? <TypingUser {...props} user={users[element++]} />
: c
);
} catch (e) {
console.error(e);
}
return children;
}
});