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.native.ts 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { Linking } from 'react-native';
  2. import { appNavigate } from '../app/actions.native';
  3. import { IStore } from '../app/types';
  4. import { conferenceLeft } from '../base/conference/actions';
  5. import { connectionFailed } from '../base/connection/actions.native';
  6. import { set } from '../base/redux/functions';
  7. import { CANCEL_LOGIN } from './actionTypes';
  8. import { stopWaitForOwner } from './actions.any';
  9. export * from './actions.any';
  10. /**
  11. * Cancels {@ink LoginDialog}.
  12. *
  13. * @returns {{
  14. * type: CANCEL_LOGIN
  15. * }}
  16. */
  17. export function cancelLogin() {
  18. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  19. dispatch({ type: CANCEL_LOGIN });
  20. // XXX The error associated with CONNECTION_FAILED was marked as
  21. // recoverable by the authentication feature and, consequently,
  22. // recoverable-aware features such as mobile's external-api did not
  23. // deliver the CONFERENCE_FAILED to the SDK clients/consumers (as
  24. // a reaction to CONNECTION_FAILED). Since the
  25. // app/user is going to navigate to WelcomePage, the SDK
  26. // clients/consumers need an event.
  27. const { error = { recoverable: undefined }, passwordRequired }
  28. = getState()['features/base/connection'];
  29. passwordRequired
  30. && dispatch(
  31. connectionFailed(
  32. passwordRequired,
  33. set(error, 'recoverable', false) as any));
  34. };
  35. }
  36. /**
  37. * Cancels {@link WaitForOwnerDialog}. Will navigate back to the welcome page.
  38. *
  39. * @returns {Function}
  40. */
  41. export function cancelWaitForOwner() {
  42. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  43. dispatch(stopWaitForOwner());
  44. // XXX The error associated with CONFERENCE_FAILED was marked as
  45. // recoverable by the feature room-lock and, consequently,
  46. // recoverable-aware features such as mobile's external-api did not
  47. // deliver the CONFERENCE_FAILED to the SDK clients/consumers. Since the
  48. // app/user is going to navigate to WelcomePage, the SDK
  49. // clients/consumers need an event.
  50. const { authRequired } = getState()['features/base/conference'];
  51. if (authRequired) {
  52. dispatch(conferenceLeft(authRequired));
  53. // in case we are showing lobby and on top of it wait for owner
  54. // we do not want to navigate away from the conference
  55. dispatch(appNavigate(undefined));
  56. }
  57. };
  58. }
  59. /**
  60. * Redirect to the default location (e.g. Welcome page).
  61. *
  62. * @returns {Function}
  63. */
  64. export function redirectToDefaultLocation() {
  65. return (dispatch: IStore['dispatch']) => dispatch(appNavigate(undefined));
  66. }
  67. /**
  68. * Opens token auth URL page.
  69. *
  70. * @param {string} tokenAuthServiceUrl - Authentication service URL.
  71. *
  72. * @returns {Function}
  73. */
  74. export function openTokenAuthUrl(tokenAuthServiceUrl: string) {
  75. return () => {
  76. Linking.openURL(tokenAuthServiceUrl);
  77. };
  78. }