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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @flow
  2. import { getCurrentConference } from '../base/conference';
  3. /**
  4. * Selector to return lobby enable state.
  5. *
  6. * @param {any} state - State object.
  7. * @returns {boolean}
  8. */
  9. export function getLobbyEnabled(state: any) {
  10. return state['features/lobby'].lobbyEnabled;
  11. }
  12. /**
  13. * Selector to return a list of knocking participants.
  14. *
  15. * @param {any} state - State object.
  16. * @returns {Array<Object>}
  17. */
  18. export function getKnockingParticipants(state: any) {
  19. return state['features/lobby'].knockingParticipants;
  20. }
  21. /**
  22. * Selector to return lobby visibility.
  23. *
  24. * @param {any} state - State object.
  25. * @returns {any}
  26. */
  27. export function getIsLobbyVisible(state: any) {
  28. return state['features/lobby'].lobbyVisible;
  29. }
  30. /**
  31. * Selector to return array with knocking participant ids.
  32. *
  33. * @param {any} state - State object.
  34. * @returns {Array}
  35. */
  36. export function getKnockingParticipantsById(state: any) {
  37. return getKnockingParticipants(state).map(participant => participant.id);
  38. }
  39. /**
  40. * Function that handles the visibility of the lobby chat message.
  41. *
  42. * @param {Object} participant - Lobby Participant.
  43. * @returns {Function}
  44. */
  45. export function showLobbyChatButton(
  46. participant: Object
  47. ) {
  48. return function(state: Object) {
  49. const { enableLobbyChat = true } = state['features/base/config'];
  50. const { lobbyMessageRecipient, isLobbyChatActive } = state['features/chat'];
  51. const conference = getCurrentConference(state);
  52. const lobbyLocalId = conference?.myLobbyUserId();
  53. if (!enableLobbyChat) {
  54. return false;
  55. }
  56. if (!isLobbyChatActive
  57. && (!participant.chattingWithModerator
  58. || participant.chattingWithModerator === lobbyLocalId)
  59. ) {
  60. return true;
  61. }
  62. if (isLobbyChatActive && lobbyMessageRecipient
  63. && participant.id !== lobbyMessageRecipient.id
  64. && (!participant.chattingWithModerator
  65. || participant.chattingWithModerator === lobbyLocalId)) {
  66. return true;
  67. }
  68. return false;
  69. };
  70. }