Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,28 @@ function App() {
showNotification({ title: `${message.sender.username} send a message`, message: message.message })
}
})

// Global voice call event listeners
socket.on('call-offer', ({ from, conversationId }) => {
const currentPath = window.location.pathname;
const currentConversationId = currentPath.split('messages/')[1];

// Only show notification if user is not in the conversation where call is happening
if (!currentConversationId || currentConversationId !== conversationId) {
showNotification({
title: `Incoming voice call`,
message: 'Click to view the conversation',
onClick: () => {
window.location.href = `/messages/${conversationId}`;
}
});
}
});

return () => {
socket.off('notificaiton');
socket.off('message');
socket.off('call-offer');
};
// eslint-disable-next-line
}, [socket])
Expand Down
Loading