選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

rootNavigationContainerRef.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react';
  2. import { toState } from '../../base/redux';
  3. import { isWelcomePageEnabled } from '../../welcome/functions';
  4. import { _sendReadyToClose } from '../external-api/functions';
  5. import { screen } from './routes';
  6. export const rootNavigationRef = React.createRef();
  7. /**
  8. * User defined navigation action included inside the reference to the container.
  9. *
  10. * @param {string} name - Destination name of the route that has been defined somewhere.
  11. * @param {Object} params - Params to pass to the destination route.
  12. * @returns {Function}
  13. */
  14. export function navigateRoot(name: string, params?: Object) {
  15. return rootNavigationRef.current?.navigate(name, params);
  16. }
  17. /**
  18. * User defined navigation action included inside the reference to the container.
  19. *
  20. * @returns {Function}
  21. */
  22. export function goBack() {
  23. return rootNavigationRef.current?.goBack();
  24. }
  25. /**
  26. * Navigates back to Welcome page, if it's available.
  27. *
  28. * @param {Object|Function} stateful - Either the whole Redux state object or the Redux store's {@code getState} method.
  29. * @param {Function} dispatch - Redux dispatch function.
  30. * @returns {void}
  31. */
  32. export function goBackToRoot(stateful: Function | Object, dispatch: Function) {
  33. const state = toState(stateful);
  34. if (isWelcomePageEnabled(state)) {
  35. navigateRoot(screen.welcome.main);
  36. } else {
  37. // For JitsiSDK, WelcomePage is not available
  38. _sendReadyToClose(dispatch);
  39. }
  40. }