Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat: Shows dialog when about to navigate away on login.
damenchoe37dd73b9e57
diff --git a/lang/main.json b/lang/main.jsonindex 875948a1d8..d2b5e531c4 100644--- a/lang/main.json+++ b/lang/main.json@@ -329,6 +329,7 @@"lockRoom": "Add meeting $t(lockRoomPassword)","lockTitle": "Lock failed","login": "Login",+ "loginQuestion": "Are you sure you want to login and leave the conference?","logoutQuestion": "Are you sure you want to logout and leave the conference?","logoutTitle": "Logout","maxUsersLimitReached": "The limit for maximum number of participants has been reached. The conference is full. Please contact the meeting owner or try again later!",diff --git a/react/features/authentication/components/index.native.ts b/react/features/authentication/components/index.native.tsindex 12ba899149..fb82e85fb9 100644--- a/react/features/authentication/components/index.native.ts+++ b/react/features/authentication/components/index.native.ts@@ -1,2 +1,3 @@export { default as LoginDialog } from './native/LoginDialog';+export const LoginQuestionDialog = undefined;export { default as WaitForOwnerDialog } from './native/WaitForOwnerDialog';diff --git a/react/features/authentication/components/index.web.ts b/react/features/authentication/components/index.web.tsindex 3f648f2342..97f7606533 100644--- a/react/features/authentication/components/index.web.ts+++ b/react/features/authentication/components/index.web.ts@@ -1,2 +1,3 @@export { default as LoginDialog } from './web/LoginDialog';+export { default as LoginQuestionDialog } from './web/LoginQuestionDialog';export { default as WaitForOwnerDialog } from './web/WaitForOwnerDialog';diff --git a/react/features/authentication/components/web/LoginQuestionDialog.tsx b/react/features/authentication/components/web/LoginQuestionDialog.tsxnew file mode 100644index 0000000000..0f88db1445--- /dev/null+++ b/react/features/authentication/components/web/LoginQuestionDialog.tsx@@ -0,0 +1,38 @@+import React from 'react';+import { useTranslation } from 'react-i18next';++import Dialog from '../../../base/ui/components/web/Dialog';++/**+ * The type of {@link LoginQuestionDialog}'s React {@code Component} props.+ */+interface IProps {++ /**+ * The handler.+ */+ handler: () => void;+}++/**+ * Implements the dialog that warns the user that the login will leave the conference.+ *+ * @param {Object} props - The props of the component.+ * @returns {React$Element}.+ */+const LoginQuestionDialog = ({ handler }: IProps) => {+ const { t } = useTranslation();++ return (+ <Dialog+ ok = {{ translationKey: 'dialog.Yes' }}+ onSubmit = { handler }+ titleKey = { t('dialog.login') }>+ <div>+ { t('dialog.loginQuestion') }+ </div>+ </Dialog>+ );+};++export default LoginQuestionDialog;diff --git a/react/features/authentication/middleware.ts b/react/features/authentication/middleware.tsindex cff08930c2..1349d634a6 100644--- a/react/features/authentication/middleware.ts+++ b/react/features/authentication/middleware.ts@@ -8,7 +8,7 @@ import {import { isRoomValid } from '../base/conference/functions';import { CONNECTION_ESTABLISHED, CONNECTION_FAILED } from '../base/connection/actionTypes';import { hangup } from '../base/connection/actions';-import { hideDialog } from '../base/dialog/actions';+import { hideDialog, openDialog } from '../base/dialog/actions';import { isDialogOpen } from '../base/dialog/functions';import {JitsiConferenceErrors,@@ -37,7 +37,7 @@ import {stopWaitForOwner,waitForOwner} from './actions';-import { LoginDialog, WaitForOwnerDialog } from './components';+import { LoginDialog, LoginQuestionDialog, WaitForOwnerDialog } from './components';import { getTokenAuthUrl, isTokenAuthEnabled } from './functions';/**@@ -301,10 +301,17 @@ function _handleLogin({ dispatch, getState }: IStore) {// FIXME: This method will not preserve the other URL params that were originally passed.const tokenAuthServiceUrl = getTokenAuthUrl(config, room);- if (tokenAuthServiceUrl) {- // we have already shown the prejoin screen, so no need to show it again after obtaining the token- window.location.href = `${tokenAuthServiceUrl}${- tokenAuthServiceUrl.includes('#') ? '&' : '#'}skipPrejoin=true`;+ if (tokenAuthServiceUrl && LoginQuestionDialog) {+ dispatch(openDialog(LoginQuestionDialog, {+ handler: () => {+ // give time for the dialog to close+ setTimeout(() => {+ // we have already shown the prejoin screen, no need to show it again after obtaining the token+ window.location.href = `${tokenAuthServiceUrl}${+ tokenAuthServiceUrl.includes('#') ? '&' : '#'}skipPrejoin=true`;+ }, 500);+ }+ }));}} else {dispatch(openLoginDialog());