fix: fix chat was crashing sometimes

This commit is contained in:
Vitaly Turovsky 2025-07-20 10:06:57 +03:00
commit b9c8ade9bf
2 changed files with 5 additions and 1 deletions

View file

@ -278,6 +278,10 @@ export async function connect (connectOptions: ConnectOptions) {
return
}
}
if (e.reason?.stack?.includes('chrome-extension://')) {
// ignore issues caused by chrome extension
return
}
handleError(e.reason)
}, {
signal: errorAbortController.signal

View file

@ -45,7 +45,7 @@ const MessageLine = ({ message, currentPlayerName, chatOpened }: { message: Mess
return <li className={Object.entries(classes).filter(([, val]) => val).map(([name]) => name).join(' ')} data-time={message.timestamp ? new Date(message.timestamp).toLocaleString('en-US', { hour12: false }) : undefined}>
{message.parts.map((msg, i) => {
// Check if this is a text part that might contain a mention
if (msg.text && currentPlayerName) {
if (typeof msg.text === 'string' && currentPlayerName) {
const parts = msg.text.split(new RegExp(`(@${currentPlayerName})`, 'i'))
if (parts.length > 1) {
return parts.map((txtPart, j) => {