diff --git a/client/src/App.jsx b/client/src/App.jsx index 59f051048..bf02e6648 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -45,6 +45,23 @@ function App() { updateOnlineStatus(onlineStatus); }, [onlineStatus]); + useEffect(() => { + const handleBeforeUnload = (event) => { + // Check if user is in chat mode (on /founduser route) + const isInChat = window.location.pathname === '/founduser'; + if (isInChat) { + event.preventDefault(); + event.returnValue = ''; + return ''; + } + }; + + window.addEventListener('beforeunload', handleBeforeUnload); + return () => { + window.removeEventListener('beforeunload', handleBeforeUnload); + }; + }, []); + return (