Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
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.
jitsi-meet/react/features/toolbox/actions.native.js

253 lines
5.7 KiB

9 years ago
/* @flow */
import type { Dispatch } from 'redux-thunk';
import {
9 years ago
CLEAR_TOOLBOX_TIMEOUT,
9 years ago
SET_SUBJECT,
SET_SUBJECT_SLIDE_IN,
SET_TOOLBAR_BUTTON,
SET_TOOLBAR_HOVERED,
SET_TOOLBOX_ALWAYS_VISIBLE,
SET_TOOLBOX_ENABLED,
9 years ago
SET_TOOLBOX_TIMEOUT,
SET_TOOLBOX_TIMEOUT_MS,
SET_TOOLBOX_VISIBLE
9 years ago
} from './actionTypes';
/**
* FIXME: We should make sure all common functions for native and web are
* merged in a global functions file.
*/
import { getButton } from './functions.native';
9 years ago
/**
* 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 buttonName = 'raisehand';
const button = getButton(buttonName, getState());
9 years ago
button.toggled = handRaised;
dispatch(setToolbarButton(buttonName, button));
};
}
/**
9 years ago
* Signals that toolbox timeout should be cleared.
9 years ago
*
* @returns {{
9 years ago
* type: CLEAR_TOOLBOX_TIMEOUT
9 years ago
* }}
*/
9 years ago
export function clearToolboxTimeout(): Object {
9 years ago
return {
9 years ago
type: CLEAR_TOOLBOX_TIMEOUT
9 years ago
};
}
/**
9 years ago
* Signals that value of conference subject should be changed.
9 years ago
*
9 years ago
* @param {string} subject - Conference subject string.
* @returns {Object}
9 years ago
*/
9 years ago
export function setSubject(subject: string): Object {
9 years ago
return {
type: SET_SUBJECT,
subject
};
}
/**
9 years ago
* Signals that toolbox subject slide in value should be changed.
9 years ago
*
9 years ago
* @param {boolean} subjectSlideIn - True if the subject is shown; otherwise,
* false.
9 years ago
* @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,
9 years ago
* button: Object,
* buttonName: string
9 years ago
* }}
*/
export function setToolbarButton(buttonName: string, button: Object): Object {
return {
type: SET_TOOLBAR_BUTTON,
9 years ago
button,
buttonName
9 years ago
};
}
/**
* 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
};
}
9 years ago
/* eslint-disable flowtype/space-before-type-colon */
/**
* Enables/disables the toolbox.
*
* @param {boolean} enabled - True to enable the toolbox or false to disable it.
* @returns {{
* type: SET_TOOLBOX_ENABLED,
* enabled: boolean
* }}
*/
export function setToolboxEnabled(enabled: boolean): Object {
return {
type: SET_TOOLBOX_ENABLED,
enabled
};
}
9 years ago
/**
* Dispatches an action which sets new timeout and clears the previous one.
*
* @param {Function} handler - Function to be invoked after the timeout.
9 years ago
* @param {number} timeoutMS - Delay.
9 years ago
* @returns {{
9 years ago
* type: SET_TOOLBOX_TIMEOUT,
* handler: Function,
* timeoutMS: number
9 years ago
* }}
*/
9 years ago
export function setToolboxTimeout(handler: Function, timeoutMS: number)
: Object {
9 years ago
return {
9 years ago
type: SET_TOOLBOX_TIMEOUT,
9 years ago
handler,
9 years ago
timeoutMS
9 years ago
};
}
9 years ago
/* eslint-enable flowtype/space-before-type-colon */
9 years ago
/**
9 years ago
* Dispatches an action which sets new toolbox timeout value.
9 years ago
*
9 years ago
* @param {number} timeoutMS - Delay.
9 years ago
* @returns {{
9 years ago
* type: SET_TOOLBOX_TIMEOUT_MS,
* timeoutMS: number
9 years ago
* }}
*/
9 years ago
export function setToolboxTimeoutMS(timeoutMS: number): Object {
9 years ago
return {
9 years ago
type: SET_TOOLBOX_TIMEOUT_MS,
timeoutMS
9 years ago
};
}
/**
9 years ago
* Shows/hides the toolbox.
9 years ago
*
9 years ago
* @param {boolean} visible - True to show the toolbox or false to hide it.
9 years ago
* @returns {{
9 years ago
* type: SET_TOOLBOX_VISIBLE,
9 years ago
* visible: boolean
* }}
*/
9 years ago
export function setToolboxVisible(visible: boolean): Object {
9 years ago
return {
9 years ago
type: SET_TOOLBOX_VISIBLE,
9 years ago
visible
};
}
/**
* 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 buttonName = 'fullscreen';
const button = getButton(buttonName, getState());
9 years ago
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 button = getButton(buttonName, getState());
9 years ago
dispatch(setToolbarButton(buttonName, {
toggled: !button.toggled
}));
};
}