Replace he html decoding lib with entities

This commit is contained in:
Gabe Kangas
2023-01-09 15:59:25 -08:00
parent c542dc10da
commit bd3c81c353
3 changed files with 41 additions and 13 deletions

View File

@@ -1,11 +1,10 @@
/* eslint-disable react/no-danger */
import { FC, ReactNode, useEffect, useState } from 'react';
import he from 'he';
import cn from 'classnames';
import { Tooltip } from 'antd';
import { LinkOutlined } from '@ant-design/icons';
import { useRecoilValue } from 'recoil';
import dynamic from 'next/dynamic';
import { decodeHTML } from 'entities';
import styles from './ChatUserMessage.module.scss';
import { formatTimestamp } from './messageFmt';
import { ChatMessage } from '../../../interfaces/chat-message.model';
@@ -15,6 +14,8 @@ import { User } from '../../../interfaces/user.model';
// Lazy loaded components
const Tooltip = dynamic(() => import('antd').then(mod => mod.Tooltip));
const ChatModerationActionMenu = dynamic(() =>
import('../ChatModerationActionMenu/ChatModerationActionMenu').then(
mod => mod.ChatModerationActionMenu,
@@ -80,10 +81,8 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
);
}
// TODO: Find a solution to get rid of or replace "he" library since
// it's overly large for only use in this one place.
useEffect(() => {
setFormattedMessage(he.decode(body));
setFormattedMessage(decodeHTML(body));
}, [message]);
return (