Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

actions.web.ts 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // @ts-expect-error
  2. import { API_ID } from '../../../modules/API';
  3. import { setRoom } from '../base/conference/actions';
  4. import {
  5. configWillLoad,
  6. setConfig
  7. } from '../base/config/actions';
  8. import { setLocationURL } from '../base/connection/actions.web';
  9. import { loadConfig } from '../base/lib-jitsi-meet/functions.web';
  10. import { inIframe } from '../base/util/iframeUtils';
  11. import { parseURIString } from '../base/util/uri';
  12. import { isVpaasMeeting } from '../jaas/functions';
  13. import { clearNotifications, showNotification } from '../notifications/actions';
  14. import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
  15. import { isWelcomePageEnabled } from '../welcome/functions';
  16. import {
  17. maybeRedirectToTokenAuthUrl,
  18. redirectToStaticPage,
  19. redirectWithStoredParams,
  20. reloadWithStoredParams
  21. } from './actions.any';
  22. import { getDefaultURL, getName } from './functions.web';
  23. import logger from './logger';
  24. import { IStore } from './types';
  25. export * from './actions.any';
  26. /**
  27. * Triggers an in-app navigation to a specific route. Allows navigation to be
  28. * abstracted between the mobile/React Native and Web/React applications.
  29. *
  30. * @param {string|undefined} uri - The URI to which to navigate. It may be a
  31. * full URL with an HTTP(S) scheme, a full or partial URI with the app-specific
  32. * scheme, or a mere room name.
  33. * @returns {Function}
  34. */
  35. export function appNavigate(uri?: string) {
  36. return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  37. let location = parseURIString(uri);
  38. // If the specified location (URI) does not identify a host, use the app's
  39. // default.
  40. if (!location?.host) {
  41. const defaultLocation = parseURIString(getDefaultURL(getState));
  42. if (location) {
  43. location.host = defaultLocation.host;
  44. // FIXME Turn location's host, hostname, and port properties into
  45. // setters in order to reduce the risks of inconsistent state.
  46. location.hostname = defaultLocation.hostname;
  47. location.pathname
  48. = defaultLocation.pathname + location.pathname.substr(1);
  49. location.port = defaultLocation.port;
  50. location.protocol = defaultLocation.protocol;
  51. } else {
  52. location = defaultLocation;
  53. }
  54. }
  55. location.protocol || (location.protocol = 'https:');
  56. const { room } = location;
  57. const locationURL = new URL(location.toString());
  58. // There are notifications now that gets displayed after we technically left
  59. // the conference, but we're still on the conference screen.
  60. dispatch(clearNotifications());
  61. dispatch(configWillLoad(locationURL, room));
  62. const config = await loadConfig();
  63. dispatch(setLocationURL(locationURL));
  64. dispatch(setConfig(config));
  65. dispatch(setRoom(room));
  66. };
  67. }
  68. /**
  69. * Check if the welcome page is enabled and redirects to it.
  70. * If requested show a thank you dialog before that.
  71. * If we have a close page enabled, redirect to it without
  72. * showing any other dialog.
  73. *
  74. * @param {Object} options - Used to decide which particular close page to show
  75. * or if close page is disabled, whether we should show the thankyou dialog.
  76. * @param {boolean} options.showThankYou - Whether we should
  77. * show thank you dialog.
  78. * @param {boolean} options.feedbackSubmitted - Whether feedback was submitted.
  79. * @returns {Function}
  80. */
  81. export function maybeRedirectToWelcomePage(options: { feedbackSubmitted?: boolean; showThankYou?: boolean; } = {}) {
  82. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  83. const {
  84. enableClosePage
  85. } = getState()['features/base/config'];
  86. // if close page is enabled redirect to it, without further action
  87. if (enableClosePage) {
  88. if (isVpaasMeeting(getState())) {
  89. const isOpenedInIframe = inIframe();
  90. if (isOpenedInIframe) {
  91. // @ts-ignore
  92. window.location = 'about:blank';
  93. } else {
  94. dispatch(redirectToStaticPage('/'));
  95. }
  96. return;
  97. }
  98. const { jwt } = getState()['features/base/jwt'];
  99. let hashParam;
  100. // save whether current user is guest or not, and pass auth token,
  101. // before navigating to close page
  102. window.sessionStorage.setItem('guest', (!jwt).toString());
  103. window.sessionStorage.setItem('jwt', jwt ?? '');
  104. let path = 'close.html';
  105. if (interfaceConfig.SHOW_PROMOTIONAL_CLOSE_PAGE) {
  106. if (Number(API_ID) === API_ID) {
  107. hashParam = `#jitsi_meet_external_api_id=${API_ID}`;
  108. }
  109. path = 'close3.html';
  110. } else if (!options.feedbackSubmitted) {
  111. path = 'close2.html';
  112. }
  113. dispatch(redirectToStaticPage(`static/${path}`, hashParam));
  114. return;
  115. }
  116. // else: show thankYou dialog only if there is no feedback
  117. if (options.showThankYou) {
  118. dispatch(showNotification({
  119. titleArguments: { appName: getName() },
  120. titleKey: 'dialog.thankYou'
  121. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  122. }
  123. // if Welcome page is enabled redirect to welcome page after 3 sec, if
  124. // there is a thank you message to be shown, 0.5s otherwise.
  125. if (isWelcomePageEnabled(getState())) {
  126. setTimeout(
  127. () => {
  128. dispatch(redirectWithStoredParams('/'));
  129. },
  130. options.showThankYou ? 3000 : 500);
  131. }
  132. };
  133. }
  134. /**
  135. * Reloads the page.
  136. *
  137. * @protected
  138. * @returns {Function}
  139. */
  140. export function reloadNow() {
  141. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  142. const state = getState();
  143. const { locationURL } = state['features/base/connection'];
  144. const reloadAction = () => {
  145. logger.info(`Reloading the conference using URL: ${locationURL}`);
  146. dispatch(reloadWithStoredParams());
  147. };
  148. if (maybeRedirectToTokenAuthUrl(dispatch, getState, reloadAction)) {
  149. return;
  150. }
  151. reloadAction();
  152. };
  153. }