2022-11-23 09:12:26 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
|
|
|
import { getCurrentConference } from '../base/conference/functions';
|
|
|
|
|
|
|
|
import { IKnockingParticipant } from './types';
|
2020-04-15 13:13:43 +00:00
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
/**
|
2021-08-18 11:29:41 +00:00
|
|
|
* Selector to return lobby enable state.
|
|
|
|
*
|
2022-11-23 09:12:26 +00:00
|
|
|
* @param {IReduxState} state - State object.
|
2021-08-18 11:29:41 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-23 09:12:26 +00:00
|
|
|
export function getLobbyEnabled(state: IReduxState) {
|
2021-08-18 11:29:41 +00:00
|
|
|
return state['features/lobby'].lobbyEnabled;
|
2021-04-21 13:48:05 +00:00
|
|
|
}
|
2021-07-06 19:07:52 +00:00
|
|
|
|
2021-08-18 11:29:41 +00:00
|
|
|
/**
|
|
|
|
* Selector to return a list of knocking participants.
|
|
|
|
*
|
2022-11-23 09:12:26 +00:00
|
|
|
* @param {IReduxState} state - State object.
|
2021-08-18 11:29:41 +00:00
|
|
|
* @returns {Array<Object>}
|
|
|
|
*/
|
2022-11-23 09:12:26 +00:00
|
|
|
export function getKnockingParticipants(state: IReduxState) {
|
2021-08-18 11:29:41 +00:00
|
|
|
return state['features/lobby'].knockingParticipants;
|
|
|
|
}
|
2021-07-06 19:07:52 +00:00
|
|
|
|
2021-08-20 08:53:11 +00:00
|
|
|
/**
|
|
|
|
* Selector to return lobby visibility.
|
|
|
|
*
|
2022-11-23 09:12:26 +00:00
|
|
|
* @param {IReduxState} state - State object.
|
2021-08-20 08:53:11 +00:00
|
|
|
* @returns {any}
|
|
|
|
*/
|
2022-11-23 09:12:26 +00:00
|
|
|
export function getIsLobbyVisible(state: IReduxState) {
|
2021-08-20 08:53:11 +00:00
|
|
|
return state['features/lobby'].lobbyVisible;
|
|
|
|
}
|
|
|
|
|
2021-07-06 19:07:52 +00:00
|
|
|
/**
|
2021-07-13 13:17:20 +00:00
|
|
|
* Selector to return array with knocking participant ids.
|
2021-07-06 19:07:52 +00:00
|
|
|
*
|
2022-11-23 09:12:26 +00:00
|
|
|
* @param {IReduxState} state - State object.
|
2021-07-06 19:07:52 +00:00
|
|
|
* @returns {Array}
|
|
|
|
*/
|
2022-11-23 09:12:26 +00:00
|
|
|
export function getKnockingParticipantsById(state: IReduxState) {
|
2021-08-18 11:29:41 +00:00
|
|
|
return getKnockingParticipants(state).map(participant => participant.id);
|
2021-07-06 19:07:52 +00:00
|
|
|
}
|
2022-03-03 17:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that handles the visibility of the lobby chat message.
|
|
|
|
*
|
|
|
|
* @param {Object} participant - Lobby Participant.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function showLobbyChatButton(
|
2022-11-23 09:12:26 +00:00
|
|
|
participant: IKnockingParticipant
|
2022-03-03 17:29:38 +00:00
|
|
|
) {
|
2022-11-23 09:12:26 +00:00
|
|
|
return function(state: IReduxState) {
|
2022-03-03 17:29:38 +00:00
|
|
|
|
|
|
|
const { enableLobbyChat = true } = state['features/base/config'];
|
|
|
|
const { lobbyMessageRecipient, isLobbyChatActive } = state['features/chat'];
|
|
|
|
const conference = getCurrentConference(state);
|
|
|
|
|
2022-03-29 11:13:28 +00:00
|
|
|
const lobbyLocalId = conference?.myLobbyUserId();
|
2022-03-03 17:29:38 +00:00
|
|
|
|
|
|
|
if (!enableLobbyChat) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isLobbyChatActive
|
|
|
|
&& (!participant.chattingWithModerator
|
|
|
|
|| participant.chattingWithModerator === lobbyLocalId)
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isLobbyChatActive && lobbyMessageRecipient
|
|
|
|
&& participant.id !== lobbyMessageRecipient.id
|
|
|
|
&& (!participant.chattingWithModerator
|
|
|
|
|| participant.chattingWithModerator === lobbyLocalId)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|