mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Chat fixes: clickable links, unread on prev messages fix
This commit is contained in:
parent
050ac0c609
commit
732c8c3df8
1 changed files with 14 additions and 5 deletions
|
@ -2,6 +2,8 @@ import React from 'react'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import io from 'socket.io-client'
|
import io from 'socket.io-client'
|
||||||
|
|
||||||
|
import linkifyHtml from 'linkify-html'
|
||||||
|
|
||||||
import constants from '../constants.json'
|
import constants from '../constants.json'
|
||||||
import LoadingIndicator from '../components/LoadingIndicator'
|
import LoadingIndicator from '../components/LoadingIndicator'
|
||||||
import styles from './chat.module.css'
|
import styles from './chat.module.css'
|
||||||
|
@ -231,10 +233,7 @@ export default class Chat extends React.Component {
|
||||||
...msgGroup,
|
...msgGroup,
|
||||||
lastLoaded: !hasMore,
|
lastLoaded: !hasMore,
|
||||||
msgs: msgGroup.msgs.map((msg) => {
|
msgs: msgGroup.msgs.map((msg) => {
|
||||||
return {
|
return msg
|
||||||
...msg,
|
|
||||||
unread: 0,
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -537,7 +536,17 @@ export default class Chat extends React.Component {
|
||||||
const { msg, type } = message
|
const { msg, type } = message
|
||||||
|
|
||||||
if (type === 'text') {
|
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') {
|
} else if (type === 'img') {
|
||||||
return (
|
return (
|
||||||
<a key={key} href={msg} rel="noreferrer" target="_blank">
|
<a key={key} href={msg} rel="noreferrer" target="_blank">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue