Chat fixes: clickable links, unread on prev messages fix

This commit is contained in:
mrfry 2021-12-22 16:35:17 +01:00
parent 050ac0c609
commit 732c8c3df8

View file

@ -2,6 +2,8 @@ import React from 'react'
import Head from 'next/head'
import io from 'socket.io-client'
import linkifyHtml from 'linkify-html'
import constants from '../constants.json'
import LoadingIndicator from '../components/LoadingIndicator'
import styles from './chat.module.css'
@ -231,10 +233,7 @@ export default class Chat extends React.Component {
...msgGroup,
lastLoaded: !hasMore,
msgs: msgGroup.msgs.map((msg) => {
return {
...msg,
unread: 0,
}
return msg
}),
}
} else {
@ -537,7 +536,17 @@ export default class Chat extends React.Component {
const { msg, type } = message
if (type === 'text') {
return <div className={`${styles.messageEntry}`}>{msg}</div>
return (
<div
className={`${styles.messageEntry}`}
dangerouslySetInnerHTML={{
__html: linkifyHtml(msg, {
defaultProtocol: 'https',
target: '_blank',
}),
}}
/>
)
} else if (type === 'img') {
return (
<a key={key} href={msg} rel="noreferrer" target="_blank">