From a35a4ffbecc5557010f4b0b469748377f0f72798 Mon Sep 17 00:00:00 2001 From: Emmanuel Pelletier Date: Thu, 25 Jul 2024 15:03:03 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8(room)=20prevent=20user=20from=20mi?= =?UTF-8?q?sclicking=20out=20of=20a=20meeting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit now clicking on the header homepage link asks for confirmation when on the route page. this is quick and dirty, using browser confirm ui, and not making a difference between join page and conference page, but it'll do for now --- src/frontend/src/layout/Header.tsx | 18 ++++++++++++++++-- src/frontend/src/locales/de/rooms.json | 3 ++- src/frontend/src/locales/en/rooms.json | 3 ++- src/frontend/src/locales/fr/rooms.json | 3 ++- src/frontend/src/utils/useMatchesRoute.ts | 17 +++++++++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/frontend/src/utils/useMatchesRoute.ts diff --git a/src/frontend/src/layout/Header.tsx b/src/frontend/src/layout/Header.tsx index 55fab9a9..f03e0021 100644 --- a/src/frontend/src/layout/Header.tsx +++ b/src/frontend/src/layout/Header.tsx @@ -5,10 +5,12 @@ import { useTranslation } from 'react-i18next' import { A, Button, Popover, PopoverList, Text } from '@/primitives' import { SettingsButton } from '@/features/settings' import { authUrl, logoutUrl, useUser } from '@/features/auth' +import { useMatchesRoute } from '@/utils/useMatchesRoute' export const Header = () => { const { t } = useTranslation() - const isHome = window.location.pathname === '/' + const isHome = useMatchesRoute('home') + const isRoom = useMatchesRoute('room') const { user, isLoggedIn } = useUser() return ( @@ -25,7 +27,19 @@ export const Header = () => {
- {t('app')} + { + if ( + isRoom && + !window.confirm(t('leaveRoomPrompt', { ns: 'rooms' })) + ) { + event.preventDefault() + } + }} + to="/" + > + {t('app')} +