|
|
|
@ -5,7 +5,7 @@ import { MessageBox } from 'react-chat-elements';
|
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
|
import { useShallow } from 'zustand/react/shallow';
|
|
|
|
|
import { Emoji } from 'emoji-picker-react';
|
|
|
|
|
import { olog } from '@/utils/utils';
|
|
|
|
|
import { isEmpty, olog } from '@/utils/utils';
|
|
|
|
|
|
|
|
|
|
const Messages = ({ ...props }) => {
|
|
|
|
|
// const currentConversation = useConversationStore(useShallow((state) => state.currentConversation));
|
|
|
|
@ -21,12 +21,6 @@ const Messages = ({ ...props }) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (activeMessages.length > 0) {
|
|
|
|
|
scrollToMessage(null, activeMessages.length - 1);
|
|
|
|
|
}
|
|
|
|
|
}, [activeMessages]);
|
|
|
|
|
|
|
|
|
|
const messageRefs = useRef([]);
|
|
|
|
|
messageRefs.current = activeMessages.map((_, i) => messageRefs.current[i] ?? createRef());
|
|
|
|
|
|
|
|
|
@ -36,6 +30,13 @@ const Messages = ({ ...props }) => {
|
|
|
|
|
referance.current.scrollTop = referance.current.scrollHeight;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (activeMessages.length > 0) {
|
|
|
|
|
// toBottom();
|
|
|
|
|
scrollToMessage(null, activeMessages.length - 1);
|
|
|
|
|
}
|
|
|
|
|
}, [activeMessages]);
|
|
|
|
|
|
|
|
|
|
const [previewVisible, setPreviewVisible] = useState(false);
|
|
|
|
|
const [previewSrc, setPreviewSrc] = useState();
|
|
|
|
|
const onPreviewClose = () => {
|
|
|
|
@ -67,7 +68,7 @@ const Messages = ({ ...props }) => {
|
|
|
|
|
// if (/\p{Emoji}\uFE0F?/u.test(part)) {
|
|
|
|
|
if (/\p{Emoji_Presentation}/u.test(part)) {
|
|
|
|
|
const code = [...part].map((e) => e.codePointAt(0).toString(16)).join(`-`);
|
|
|
|
|
return <Emoji key={`${part}${index}${code}`} unified={code} size={24} emojiStyle={'apple'} />;
|
|
|
|
|
return <Emoji key={`${part}${index}${code}`} unified={code} size={24} emojiStyle={'google'} />;
|
|
|
|
|
} else if (/https?:\/\/[\S]+/gi.test(part)) {
|
|
|
|
|
return (
|
|
|
|
|
<a href={part} target='_blank' key={`${part}${index}`} rel='noreferrer'>
|
|
|
|
|