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 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // @flow
  2. import _ from 'lodash';
  3. import { getCurrentConference } from '../base/conference';
  4. import { toState } from '../base/redux';
  5. import { FEATURE_KEY } from './constants';
  6. /**
  7. * Returns the rooms object for breakout rooms.
  8. *
  9. * @param {Function|Object} stateful - The redux store, the redux
  10. * {@code getState} function, or the redux state itself.
  11. * @returns {Object} Object of rooms.
  12. */
  13. export const getBreakoutRooms = (stateful: Function | Object) => toState(stateful)[FEATURE_KEY].rooms;
  14. /**
  15. * Returns the main room.
  16. *
  17. * @param {Function|Object} stateful - The redux store, the redux
  18. * {@code getState} function, or the redux state itself.
  19. * @returns {Object|undefined} The main room object, or undefined.
  20. */
  21. export const getMainRoom = (stateful: Function | Object) => {
  22. const rooms = getBreakoutRooms(stateful);
  23. return _.find(rooms, (room: Object) => room.isMainRoom);
  24. };
  25. /**
  26. * Returns the id of the current room.
  27. *
  28. * @param {Function|Object} stateful - The redux store, the redux
  29. * {@code getState} function, or the redux state itself.
  30. * @returns {string} Room id or undefined.
  31. */
  32. export const getCurrentRoomId = (stateful: Function | Object) => {
  33. const conference = getCurrentConference(stateful);
  34. // $FlowExpectedError
  35. return conference?.getName();
  36. };
  37. /**
  38. * Determines whether the local participant is in a breakout room.
  39. *
  40. * @param {Function|Object} stateful - The redux store, the redux
  41. * {@code getState} function, or the redux state itself.
  42. * @returns {boolean}
  43. */
  44. export const isInBreakoutRoom = (stateful: Function | Object) => {
  45. const conference = getCurrentConference(stateful);
  46. // $FlowExpectedError
  47. return conference?.getBreakoutRooms()
  48. ?.isBreakoutRoom();
  49. };