aboutsummaryrefslogtreecommitdiff
path: root/vnext
diff options
context:
space:
mode:
Diffstat (limited to 'vnext')
-rw-r--r--vnext/src/components/Message.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/vnext/src/components/Message.js b/vnext/src/components/Message.js
index 1d9afe9a..6b0854a4 100644
--- a/vnext/src/components/Message.js
+++ b/vnext/src/components/Message.js
@@ -12,6 +12,7 @@ import { format } from '../utils/embed';
import './Message.css';
function Message({ data, visitor, children, ...rest }) {
+ const isCode = (data.tags || []).indexOf('code') >= 0;
return (
<div className="msg-cont">
<header className="h">
@@ -28,7 +29,7 @@ function Message({ data, visitor, children, ...rest }) {
<TagsList user={data.user} data={data.tags || []} />
</header>
<div className="msg-txt">
- <p dangerouslySetInnerHTML={{ __html: format(data.body, data.mid, (data.tags || []).indexOf('code') >= 0) }}></p>
+ <MessageContainer isCode={isCode} data={{ __html: format(data.body, data.mid, isCode) }} />
</div>
{data.photo &&
<p className="ir"><a href={`//i.juick.com/p/${data.mid}.${data.attach}`} data-fname={`${data.mid}.${data.attach}`}>
@@ -86,6 +87,10 @@ function Message({ data, visitor, children, ...rest }) {
export default React.memo(Message);
+function MessageContainer({isCode, data}) {
+ return isCode ? (<pre dangerouslySetInnerHTML={data} />) : (<p dangerouslySetInnerHTML={data} />);
+}
+
function Tags({ data, user, ...rest }) {
return data.length > 0 && (
<div className="msg-tags">