You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.web.ts 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { maybeRedirectToWelcomePage } from '../app/actions.web';
  2. import { IStore } from '../app/types';
  3. import { openDialog } from '../base/dialog/actions';
  4. import { browser } from '../base/lib-jitsi-meet';
  5. import { CANCEL_LOGIN } from './actionTypes';
  6. import LoginQuestionDialog from './components/web/LoginQuestionDialog';
  7. export * from './actions.any';
  8. /**
  9. * Cancels {@ink LoginDialog}.
  10. *
  11. * @returns {{
  12. * type: CANCEL_LOGIN
  13. * }}
  14. */
  15. export function cancelLogin() {
  16. return {
  17. type: CANCEL_LOGIN
  18. };
  19. }
  20. /**
  21. * Cancels authentication, closes {@link WaitForOwnerDialog}
  22. * and navigates back to the welcome page only in the case of authentication required error.
  23. * We can be showing the dialog while lobby is enabled and participant is still waiting there and hiding this dialog
  24. * should do nothing.
  25. *
  26. * @returns {Function}
  27. */
  28. export function cancelWaitForOwner() {
  29. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  30. const { authRequired } = getState()['features/base/conference'];
  31. authRequired && dispatch(maybeRedirectToWelcomePage());
  32. };
  33. }
  34. /**
  35. * Redirect to the default location (e.g. Welcome page).
  36. *
  37. * @returns {Function}
  38. */
  39. export function redirectToDefaultLocation() {
  40. return (dispatch: IStore['dispatch']) => dispatch(maybeRedirectToWelcomePage());
  41. }
  42. /**
  43. * Opens token auth URL page.
  44. *
  45. * @param {string} tokenAuthServiceUrl - Authentication service URL.
  46. *
  47. * @returns {Function}
  48. */
  49. export function openTokenAuthUrl(tokenAuthServiceUrl: string): any {
  50. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  51. const redirect = () => {
  52. if (browser.isElectron()) {
  53. window.open(tokenAuthServiceUrl, '_blank');
  54. } else {
  55. window.location.href = tokenAuthServiceUrl;
  56. }
  57. };
  58. // Show warning for leaving conference only when in a conference.
  59. if (!browser.isElectron() && getState()['features/base/conference'].conference) {
  60. dispatch(openDialog(LoginQuestionDialog, {
  61. handler: () => {
  62. // Give time for the dialog to close.
  63. setTimeout(() => redirect(), 500);
  64. }
  65. }));
  66. } else {
  67. redirect();
  68. }
  69. };
  70. }