diff --git a/frontend/.env.template b/frontend/.env.template index 4055e48c96107e4df5cbba1e7093d64bf957f722..e936d4f917d78af4bd59dce43e2802c03bb46637 100644 --- a/frontend/.env.template +++ b/frontend/.env.template @@ -1 +1,2 @@ -REACT_APP_BASE_URL_BACK=http://localhost:3001/api \ No newline at end of file +REACT_APP_BASE_URL_BACK=http://localhost:3001/api +REACT_APP_SOCKET_URL=ws://localhost:3001/api \ No newline at end of file diff --git a/frontend/src/components/Comments.js b/frontend/src/components/Comments.js index 1f7975a963cc88c874bada47d9431c0e63e3b09a..a3a13046f98e55ee8f203236941ba282c56c070a 100644 --- a/frontend/src/components/Comments.js +++ b/frontend/src/components/Comments.js @@ -118,10 +118,9 @@ export default function Messages({ place, infos, lastMessage }) { useEffect(() => { if (lastMessage?.data) { let new_message = JSON.parse(lastMessage.data); - if ( - (new_message.type == "news" && infos) || - (new_message.type == "comment" && !infos && new_message.comment.username != user) - ) { + if (new_message.type == "news" && infos) { + setMessages((old_messages) => [new_message.comment, ...old_messages]); + } else if (!infos && new_message.type == "comment" && new_message.comment.username != user) { setMessages((old_messages) => [...old_messages, new_message.comment]); } }