Added backlog to chat
This commit is contained in:
@@ -20,6 +20,7 @@ const PopupChat = props => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
socket.on('message', message => pushChatlog(message));
|
socket.on('message', message => pushChatlog(message));
|
||||||
|
socket.on('backlog', messages => setChatlog(prev => [...prev, ...messages]));
|
||||||
socket.on('disconnect', reason => pushChatlog({ emphasis: true, text: 'Lost connection' }));
|
socket.on('disconnect', reason => pushChatlog({ emphasis: true, text: 'Lost connection' }));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -66,6 +67,10 @@ const handleClose = setOpen => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSend = (inputRef, pushChatlog, username, accessToken) => {
|
const handleSend = (inputRef, pushChatlog, username, accessToken) => {
|
||||||
|
if (inputRef.current.value == '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
socket.emit('message', {
|
socket.emit('message', {
|
||||||
accessToken,
|
accessToken,
|
||||||
text: inputRef.current.value
|
text: inputRef.current.value
|
||||||
|
|||||||
Reference in New Issue
Block a user