Skip to content

Commit

Permalink
socket url updated to depoyed url
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajbir348 committed Feb 28, 2024
1 parent 5e2c5ec commit 1c73e58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/context/SocketContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SocketContextProvider = ({ children }) => {

useEffect(() => {
if (authUser) {
const socket = io("https://chat-app-yt.onrender.com", {
const socket = io("https://mern-chat-app-1dzi.onrender.com", {
query: {
userId: authUser._id,
},
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/hooks/useListenMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ import notificationSound from "../assets/sounds/notification.mp3";

const useListenMessages = () => {
const { socket } = useSocketContext();
const { messages, setMessages } = useConversation();
const { messages, setMessages ,selectedConversation} = useConversation();

useEffect(() => {
socket?.on("newMessage", (newMessage) => {
const check = newMessage.receiverId === selectedConversation._id
newMessage.shouldShake = true;
const sound = new Audio(notificationSound);
sound.play();
setMessages([...messages, newMessage]);
if (check) {
setMessages([...messages, newMessage]);
}
});

return () => socket?.off("newMessage");
Expand Down

0 comments on commit 1c73e58

Please sign in to comment.