2018-02-26 16:14:46 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-06-20 20:19:53 +00:00
|
|
|
import { setFollowMe, setStartMutedPolicy } from '../base/conference';
|
|
|
|
import { openDialog } from '../base/dialog';
|
|
|
|
import { i18next } from '../base/i18n';
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
import {
|
|
|
|
SET_AUDIO_SETTINGS_VISIBILITY,
|
|
|
|
SET_SETTINGS_VIEW_VISIBLE,
|
|
|
|
SET_VIDEO_SETTINGS_VISIBILITY
|
|
|
|
} from './actionTypes';
|
2018-06-20 20:19:53 +00:00
|
|
|
import { SettingsDialog } from './components';
|
|
|
|
import { getMoreTabProps, getProfileTabProps } from './functions';
|
|
|
|
|
|
|
|
declare var APP: Object;
|
2018-02-26 16:14:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the visibility of the view/UI which renders the app's settings.
|
|
|
|
*
|
|
|
|
* @param {boolean} visible - If the view/UI which renders the app's settings is
|
|
|
|
* to be made visible, {@code true}; otherwise, {@code false}.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_SETTINGS_VIEW_VISIBLE,
|
|
|
|
* visible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setSettingsViewVisible(visible: boolean) {
|
|
|
|
return {
|
|
|
|
type: SET_SETTINGS_VIEW_VISIBLE,
|
|
|
|
visible
|
|
|
|
};
|
|
|
|
}
|
2018-06-20 20:19:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens {@code SettingsDialog}.
|
|
|
|
*
|
|
|
|
* @param {string} defaultTab - The tab in {@code SettingsDialog} that should be
|
|
|
|
* displayed initially.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function openSettingsDialog(defaultTab: string) {
|
|
|
|
return openDialog(SettingsDialog, { defaultTab });
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
/**
|
|
|
|
* Sets the visiblity of the audio settings.
|
|
|
|
*
|
|
|
|
* @param {boolean} value - The new value.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
function setAudioSettingsVisibility(value: boolean) {
|
|
|
|
return {
|
|
|
|
type: SET_AUDIO_SETTINGS_VISIBILITY,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the visiblity of the video settings.
|
|
|
|
*
|
|
|
|
* @param {boolean} value - The new value.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
function setVideoSettingsVisibility(value: boolean) {
|
|
|
|
return {
|
|
|
|
type: SET_VIDEO_SETTINGS_VISIBILITY,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
2018-06-20 20:19:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Submits the settings from the "More" tab of the settings dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} newState - The new settings.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function submitMoreTab(newState: Object): Function {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const currentState = getMoreTabProps(getState());
|
|
|
|
|
|
|
|
if (newState.followMeEnabled !== currentState.followMeEnabled) {
|
|
|
|
dispatch(setFollowMe(newState.followMeEnabled));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.startAudioMuted !== currentState.startAudioMuted
|
|
|
|
|| newState.startVideoMuted !== currentState.startVideoMuted) {
|
|
|
|
dispatch(setStartMutedPolicy(
|
|
|
|
newState.startAudioMuted, newState.startVideoMuted));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.currentLanguage !== currentState.currentLanguage) {
|
|
|
|
i18next.changeLanguage(newState.currentLanguage);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Submits the settings from the "Profile" tab of the settings dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} newState - The new settings.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function submitProfileTab(newState: Object): Function {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const currentState = getProfileTabProps(getState());
|
|
|
|
|
|
|
|
if (newState.displayName !== currentState.displayName) {
|
|
|
|
APP.conference.changeLocalDisplayName(newState.displayName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.email !== currentState.email) {
|
|
|
|
APP.conference.changeLocalEmail(newState.email);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2020-03-30 14:17:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the visiblity of the audio settings.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function toggleAudioSettings() {
|
|
|
|
return (dispatch: Function, getState: Function) => {
|
|
|
|
const value = getState()['features/settings'].audioSettingsVisible;
|
|
|
|
|
|
|
|
dispatch(setAudioSettingsVisibility(!value));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the visiblity of the video settings.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function toggleVideoSettings() {
|
|
|
|
return (dispatch: Function, getState: Function) => {
|
|
|
|
const value = getState()['features/settings'].videoSettingsVisible;
|
|
|
|
|
|
|
|
dispatch(setVideoSettingsVisibility(!value));
|
|
|
|
};
|
|
|
|
}
|