2023-02-21 09:26:04 +00:00
|
|
|
// @ts-ignore
|
2020-07-21 12:21:01 +00:00
|
|
|
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
|
2022-09-26 09:54:22 +00:00
|
|
|
import { IStore } from '../app/types';
|
2020-07-21 12:21:01 +00:00
|
|
|
|
2021-02-12 11:18:16 +00:00
|
|
|
import { OPEN_CHAT } from './actionTypes';
|
|
|
|
import { closeChat } from './actions.any';
|
2020-07-21 12:21:01 +00:00
|
|
|
|
|
|
|
export * from './actions.any';
|
|
|
|
|
|
|
|
/**
|
2021-02-12 11:18:16 +00:00
|
|
|
* Displays the chat panel.
|
2020-07-21 12:21:01 +00:00
|
|
|
*
|
2021-02-12 11:18:16 +00:00
|
|
|
* @param {Object} participant - The recipient for the private chat.
|
|
|
|
* @returns {{
|
|
|
|
* participant: Participant,
|
|
|
|
* type: OPEN_CHAT
|
|
|
|
* }}
|
2020-07-21 12:21:01 +00:00
|
|
|
*/
|
2022-09-26 09:54:22 +00:00
|
|
|
export function openChat(participant?: Object) {
|
|
|
|
return function(dispatch: IStore['dispatch']) {
|
2021-02-24 12:26:00 +00:00
|
|
|
dispatch({
|
|
|
|
participant,
|
|
|
|
type: OPEN_CHAT
|
|
|
|
});
|
2020-07-21 12:21:01 +00:00
|
|
|
};
|
|
|
|
}
|
2021-02-12 11:18:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles display of the chat panel.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function toggleChat() {
|
2022-09-26 09:54:22 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-02-12 11:18:16 +00:00
|
|
|
const isOpen = getState()['features/chat'].isOpen;
|
|
|
|
|
|
|
|
if (isOpen) {
|
|
|
|
dispatch(closeChat());
|
|
|
|
} else {
|
|
|
|
dispatch(openChat());
|
|
|
|
}
|
2021-02-24 12:26:00 +00:00
|
|
|
|
|
|
|
// Recompute the large video size whenever we toggle the chat, as it takes chat state into account.
|
|
|
|
VideoLayout.onResize();
|
2021-02-12 11:18:16 +00:00
|
|
|
};
|
|
|
|
}
|