123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- /* @flow */
-
- import type { Dispatch } from 'redux-thunk';
-
- import {
- CLEAR_TOOLBOX_TIMEOUT,
- SET_DEFAULT_TOOLBOX_BUTTONS,
- SET_TOOLBOX_ALWAYS_VISIBLE,
- SET_SUBJECT,
- SET_SUBJECT_SLIDE_IN,
- SET_TOOLBAR_BUTTON,
- SET_TOOLBAR_HOVERED,
- SET_TOOLBOX_TIMEOUT,
- SET_TOOLBOX_TIMEOUT_MS,
- SET_TOOLBOX_VISIBLE
- } from './actionTypes';
- import { getDefaultToolboxButtons } from './functions';
-
- /**
- * Event handler for local raise hand changed event.
- *
- * @param {boolean} handRaised - Flag showing whether hand is raised.
- * @returns {Function}
- */
- export function changeLocalRaiseHand(handRaised: boolean): Function {
- return (dispatch: Dispatch<*>, getState: Function) => {
- const state = getState();
- const { secondaryToolbarButtons } = state['features/toolbox'];
- const buttonName = 'raisehand';
- const button = secondaryToolbarButtons.get(buttonName);
-
- button.toggled = handRaised;
-
- dispatch(setToolbarButton(buttonName, button));
- };
- }
-
- /**
- * Signals that toolbox timeout should be cleared.
- *
- * @returns {{
- * type: CLEAR_TOOLBOX_TIMEOUT
- * }}
- */
- export function clearToolboxTimeout(): Object {
- return {
- type: CLEAR_TOOLBOX_TIMEOUT
- };
- }
-
- /**
- * Enables/disables audio toolbar button.
- *
- * @param {boolean} enabled - True if the button should be enabled; otherwise,
- * false.
- * @returns {Function}
- */
- export function setAudioIconEnabled(enabled: boolean = false): Function {
- return (dispatch: Dispatch<*>) => {
- const i18nKey = enabled ? 'mute' : 'micDisabled';
- const i18n = `[content]toolbar.${i18nKey}`;
- const button = {
- enabled,
- i18n,
- toggled: !enabled
- };
-
- dispatch(setToolbarButton('microphone', button));
- };
- }
-
- /**
- * Sets the default toolbar buttons of the Toolbox.
- *
- * @returns {{
- * type: SET_DEFAULT_TOOLBOX_BUTTONS,
- * primaryToolbarButtons: Map,
- * secondaryToolbarButtons: Map
- * }}
- */
- export function setDefaultToolboxButtons(): Object {
- return {
- type: SET_DEFAULT_TOOLBOX_BUTTONS,
- ...getDefaultToolboxButtons()
- };
- }
-
- /**
- * Signals that value of conference subject should be changed.
- *
- * @param {string} subject - Conference subject string.
- * @returns {Object}
- */
- export function setSubject(subject: string): Object {
- return {
- type: SET_SUBJECT,
- subject
- };
- }
-
- /**
- * Signals that toolbox subject slide in value should be changed.
- *
- * @param {boolean} subjectSlideIn - True if the subject is shown; otherwise,
- * false.
- * @returns {{
- * type: SET_SUBJECT_SLIDE_IN,
- * subjectSlideIn: boolean
- * }}
- */
- export function setSubjectSlideIn(subjectSlideIn: boolean): Object {
- return {
- type: SET_SUBJECT_SLIDE_IN,
- subjectSlideIn
- };
- }
-
- /**
- * Signals that value of the button specified by key should be changed.
- *
- * @param {string} buttonName - Button key.
- * @param {Object} button - Button object.
- * @returns {{
- * type: SET_TOOLBAR_BUTTON,
- * button: Object,
- * buttonName: string
- * }}
- */
- export function setToolbarButton(buttonName: string, button: Object): Object {
- return {
- type: SET_TOOLBAR_BUTTON,
- button,
- buttonName
- };
- }
-
- /**
- * Signals that toolbar is hovered value should be changed.
- *
- * @param {boolean} hovered - Flag showing whether toolbar is hovered.
- * @returns {{
- * type: SET_TOOLBAR_HOVERED,
- * hovered: boolean
- * }}
- */
- export function setToolbarHovered(hovered: boolean): Object {
- return {
- type: SET_TOOLBAR_HOVERED,
- hovered
- };
- }
-
- /**
- * Signals that always visible toolbars value should be changed.
- *
- * @param {boolean} alwaysVisible - Value to be set in redux store.
- * @returns {{
- * type: SET_TOOLBOX_ALWAYS_VISIBLE,
- * alwaysVisible: boolean
- * }}
- */
- export function setToolboxAlwaysVisible(alwaysVisible: boolean): Object {
- return {
- type: SET_TOOLBOX_ALWAYS_VISIBLE,
- alwaysVisible
- };
- }
-
- /* eslint-disable flowtype/space-before-type-colon */
-
- /**
- * Dispatches an action which sets new timeout and clears the previous one.
- *
- * @param {Function} handler - Function to be invoked after the timeout.
- * @param {number} timeoutMS - Delay.
- * @returns {{
- * type: SET_TOOLBOX_TIMEOUT,
- * handler: Function,
- * timeoutMS: number
- * }}
- */
- export function setToolboxTimeout(handler: Function, timeoutMS: number)
- : Object {
- return {
- type: SET_TOOLBOX_TIMEOUT,
- handler,
- timeoutMS
- };
- }
-
- /* eslint-enable flowtype/space-before-type-colon */
-
- /**
- * Dispatches an action which sets new toolbox timeout value.
- *
- * @param {number} timeoutMS - Delay.
- * @returns {{
- * type: SET_TOOLBOX_TIMEOUT_MS,
- * timeoutMS: number
- * }}
- */
- export function setToolboxTimeoutMS(timeoutMS: number): Object {
- return {
- type: SET_TOOLBOX_TIMEOUT_MS,
- timeoutMS
- };
- }
-
- /**
- * Shows/hides the toolbox.
- *
- * @param {boolean} visible - True to show the toolbox or false to hide it.
- * @returns {{
- * type: SET_TOOLBOX_VISIBLE,
- * visible: boolean
- * }}
- */
- export function setToolboxVisible(visible: boolean): Object {
- return {
- type: SET_TOOLBOX_VISIBLE,
- visible
- };
- }
-
- /**
- * Enables/disables audio toolbar button.
- *
- * @param {boolean} enabled - True if the button should be enabled; otherwise,
- * false.
- * @returns {Function}
- */
- export function setVideoIconEnabled(enabled: boolean = false): Function {
- return (dispatch: Dispatch<*>) => {
- const i18nKey = enabled ? 'videomute' : 'cameraDisabled';
- const i18n = `[content]toolbar.${i18nKey}`;
- const button = {
- enabled,
- i18n,
- toggled: !enabled
- };
-
- dispatch(setToolbarButton('camera', button));
- };
- }
-
- /**
- * Shows etherpad button if it's not shown.
- *
- * @returns {Function}
- */
- export function showEtherpadButton(): Function {
- return (dispatch: Dispatch<*>) => {
- dispatch(setToolbarButton('etherpad', {
- hidden: false
- }));
- };
- }
-
- /**
- * Event handler for full screen toggled event.
- *
- * @param {boolean} isFullScreen - Flag showing whether app in full
- * screen mode.
- * @returns {Function}
- */
- export function toggleFullScreen(isFullScreen: boolean): Function {
- return (dispatch: Dispatch<*>, getState: Function) => {
- const state = getState();
- const { primaryToolbarButtons } = state['features/toolbox'];
- const buttonName = 'fullscreen';
- const button = primaryToolbarButtons.get(buttonName);
-
- button.toggled = isFullScreen;
-
- dispatch(setToolbarButton(buttonName, button));
- };
- }
-
- /**
- * Sets negation of button's toggle property.
- *
- * @param {string} buttonName - Button key.
- * @returns {Function}
- */
- export function toggleToolbarButton(buttonName: string): Function {
- return (dispatch: Dispatch, getState: Function) => {
- const state = getState();
- const {
- primaryToolbarButtons,
- secondaryToolbarButtons
- } = state['features/toolbox'];
- const button
- = primaryToolbarButtons.get(buttonName)
- || secondaryToolbarButtons.get(buttonName);
-
- dispatch(setToolbarButton(buttonName, {
- toggled: !button.toggled
- }));
- };
- }
|