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.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. CONFIG_WILL_LOAD,
  5. LOAD_CONFIG_ERROR,
  6. SET_CONFIG
  7. } from './actionTypes';
  8. import { setConfigFromURLParams } from './functions';
  9. /**
  10. * Signals that the configuration for a specific locationURL will be loaded now.
  11. *
  12. * @param {string|URL} locationURL - The URL of the location which necessitated
  13. * the loading of a configuration.
  14. * @returns {{
  15. * type: CONFIG_WILL_LOAD,
  16. * locationURL
  17. * }}
  18. */
  19. export function configWillLoad(locationURL: string | URL) {
  20. return {
  21. type: CONFIG_WILL_LOAD,
  22. locationURL
  23. };
  24. }
  25. /**
  26. * Signals that a configuration could not be loaded due to a specific error.
  27. *
  28. * @param {Error} error - The {@code Error} which prevented the successful
  29. * loading of a configuration.
  30. * @param {string|URL} locationURL - The URL of the location which necessitated
  31. * the loading of a configuration.
  32. * @returns {{
  33. * type: LOAD_CONFIG_ERROR,
  34. * error: Error,
  35. * locationURL
  36. * }}
  37. */
  38. export function loadConfigError(error: Error, locationURL: string | URL) {
  39. return {
  40. type: LOAD_CONFIG_ERROR,
  41. error,
  42. locationURL
  43. };
  44. }
  45. /**
  46. * Sets the configuration represented by the feature base/config. The
  47. * configuration is defined and consumed by the library lib-jitsi-meet but some
  48. * of its properties are consumed by the application jitsi-meet as well.
  49. *
  50. * @param {Object} config - The configuration to be represented by the feature
  51. * base/config.
  52. * @returns {Function}
  53. */
  54. export function setConfig(config: Object = {}) {
  55. return (dispatch: Dispatch<*>, getState: Function) => {
  56. const { locationURL } = getState()['features/base/connection'];
  57. // Now that the loading of the config was successful override the values
  58. // with the parameters passed in the hash part of the location URI.
  59. // TODO We're still in the middle ground between old Web with config,
  60. // interfaceConfig, and loggingConfig used via global variables and new
  61. // Web and mobile reading the respective values from the redux store.
  62. // On React Native there's no interfaceConfig at all yet and
  63. // loggingConfig is not loaded but there's a default value in the redux
  64. // store.
  65. // Only the config will be overridden on React Native, as the other
  66. // globals will be undefined here. It's intentional - we do not care to
  67. // override those configs yet.
  68. locationURL
  69. && setConfigFromURLParams(
  70. // On Web the config also comes from the window.config global,
  71. // but it is resolved in the loadConfig procedure.
  72. config,
  73. window.interfaceConfig,
  74. window.loggingConfig,
  75. locationURL);
  76. dispatch({
  77. type: SET_CONFIG,
  78. config
  79. });
  80. };
  81. }