TypingTweaks: Fix crashing in some languages (#2998)
This commit is contained in:
parent
64c3dd1c16
commit
ce0740b885
1 changed files with 15 additions and 7 deletions
|
@ -129,14 +129,22 @@ export default definePlugin({
|
||||||
buildSeveralUsers,
|
buildSeveralUsers,
|
||||||
|
|
||||||
mutateChildren(props: any, users: User[], children: any) {
|
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 =>
|
return children.map(c =>
|
||||||
c.type === "strong"
|
c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c))
|
||||||
? <TypingUser {...props} user={users[element++]} />
|
? <TypingUser {...props} user={users[element++]} />
|
||||||
: c
|
: c
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return children;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue