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.

functions.js 835B

12345678910111213141516171819202122232425262728
  1. /* @flow */
  2. /**
  3. * Returns current domain.
  4. *
  5. * @param {(Function|Object)} stateOrGetState - Redux getState() method or Redux
  6. * state.
  7. * @returns {(string|undefined)}
  8. */
  9. export function getDomain(stateOrGetState: Function | Object) {
  10. const state
  11. = typeof stateOrGetState === 'function'
  12. ? stateOrGetState()
  13. : stateOrGetState;
  14. const connection = state['features/base/connection'];
  15. let domain;
  16. try {
  17. domain = connection.connectionOptions.hosts.domain;
  18. } catch (e) {
  19. // XXX The value of connectionOptions or any of the properties
  20. // descending from it may be undefined at some point in the execution
  21. // (e.g. on start). Instead of multiple checks for the undefined value,
  22. // we just wrap it in a try-catch block.
  23. }
  24. return domain;
  25. }