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.ts 2.2KB

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