2021-11-10 11:19:40 +00:00
|
|
|
import { batch } from 'react-redux';
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2023-03-03 11:48:17 +00:00
|
|
|
// @ts-expect-error
|
|
|
|
import keyboardShortcut from '../../../modules/keyboardshortcut/keyboardshortcut';
|
2022-10-21 07:33:10 +00:00
|
|
|
import { IStore } from '../app/types';
|
2021-11-10 11:19:40 +00:00
|
|
|
import {
|
|
|
|
setFollowMe,
|
|
|
|
setStartMutedPolicy,
|
|
|
|
setStartReactionsMuted
|
2022-10-21 07:33:10 +00:00
|
|
|
} from '../base/conference/actions';
|
|
|
|
import { openDialog } from '../base/dialog/actions';
|
|
|
|
import i18next from '../base/i18n/i18next';
|
|
|
|
import { updateSettings } from '../base/settings/actions';
|
2018-06-20 20:19:53 +00:00
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
import {
|
|
|
|
SET_AUDIO_SETTINGS_VISIBILITY,
|
|
|
|
SET_VIDEO_SETTINGS_VISIBILITY
|
|
|
|
} from './actionTypes';
|
2022-10-21 07:33:10 +00:00
|
|
|
// eslint-disable-next-line lines-around-comment
|
|
|
|
// @ts-ignore
|
2021-04-23 15:00:51 +00:00
|
|
|
import { LogoutDialog, SettingsDialog } from './components';
|
2021-11-10 11:19:40 +00:00
|
|
|
import {
|
|
|
|
getModeratorTabProps,
|
|
|
|
getMoreTabProps,
|
2023-03-03 10:53:39 +00:00
|
|
|
getNotificationsTabProps,
|
2023-03-03 11:48:17 +00:00
|
|
|
getProfileTabProps,
|
|
|
|
getShortcutsTabProps
|
2021-11-10 11:19:40 +00:00
|
|
|
} from './functions';
|
2018-06-20 20:19:53 +00:00
|
|
|
|
2021-04-23 15:00:51 +00:00
|
|
|
/**
|
|
|
|
* Opens {@code LogoutDialog}.
|
|
|
|
*
|
|
|
|
* @param {Function} onLogout - The event in {@code LogoutDialog} that should be
|
|
|
|
* enabled on click.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function openLogoutDialog(onLogout: Function) {
|
|
|
|
return openDialog(LogoutDialog, { onLogout });
|
|
|
|
}
|
|
|
|
|
2018-06-20 20:19:53 +00:00
|
|
|
/**
|
|
|
|
* Opens {@code SettingsDialog}.
|
|
|
|
*
|
|
|
|
* @param {string} defaultTab - The tab in {@code SettingsDialog} that should be
|
|
|
|
* displayed initially.
|
2022-05-24 19:04:21 +00:00
|
|
|
* @param {boolean} isDisplayedOnWelcomePage - Indicates whether the device selection dialog is displayed on the
|
|
|
|
* welcome page or not.
|
2018-06-20 20:19:53 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function openSettingsDialog(defaultTab: string, isDisplayedOnWelcomePage?: boolean) {
|
2022-05-24 19:04:21 +00:00
|
|
|
return openDialog(SettingsDialog, {
|
|
|
|
defaultTab,
|
|
|
|
isDisplayedOnWelcomePage
|
|
|
|
});
|
2018-06-20 20:19:53 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Sets the visibility of the audio settings.
|
2020-03-30 14:17:18 +00:00
|
|
|
*
|
|
|
|
* @param {boolean} value - The new value.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
function setAudioSettingsVisibility(value: boolean) {
|
|
|
|
return {
|
|
|
|
type: SET_AUDIO_SETTINGS_VISIBILITY,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Sets the visibility of the video settings.
|
2020-03-30 14:17:18 +00:00
|
|
|
*
|
|
|
|
* @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}
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function submitMoreTab(newState: any) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2018-06-20 20:19:53 +00:00
|
|
|
const currentState = getMoreTabProps(getState());
|
|
|
|
|
2020-07-16 10:00:37 +00:00
|
|
|
const showPrejoinPage = newState.showPrejoinPage;
|
|
|
|
|
|
|
|
if (showPrejoinPage !== currentState.showPrejoinPage) {
|
2021-12-20 09:34:40 +00:00
|
|
|
dispatch(updateSettings({
|
|
|
|
userSelectedSkipPrejoin: !showPrejoinPage
|
|
|
|
}));
|
2020-07-16 10:00:37 +00:00
|
|
|
}
|
|
|
|
|
2022-09-15 07:57:48 +00:00
|
|
|
if (newState.maxStageParticipants !== currentState.maxStageParticipants) {
|
|
|
|
dispatch(updateSettings({ maxStageParticipants: Number(newState.maxStageParticipants) }));
|
2022-04-07 08:31:53 +00:00
|
|
|
}
|
2018-06-20 20:19:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-11-10 11:19:40 +00:00
|
|
|
/**
|
|
|
|
* Submits the settings from the "Moderator" tab of the settings dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} newState - The new settings.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function submitModeratorTab(newState: any) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-11-10 11:19:40 +00:00
|
|
|
const currentState = getModeratorTabProps(getState());
|
|
|
|
|
|
|
|
if (newState.followMeEnabled !== currentState.followMeEnabled) {
|
|
|
|
dispatch(setFollowMe(newState.followMeEnabled));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.startReactionsMuted !== currentState.startReactionsMuted) {
|
|
|
|
batch(() => {
|
2021-12-13 19:46:05 +00:00
|
|
|
// updating settings we want to update and backend (notify the rest of the participants)
|
|
|
|
dispatch(setStartReactionsMuted(newState.startReactionsMuted, true));
|
2021-11-10 11:19:40 +00:00
|
|
|
dispatch(updateSettings({ soundsReactions: !newState.startReactionsMuted }));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.startAudioMuted !== currentState.startAudioMuted
|
|
|
|
|| newState.startVideoMuted !== currentState.startVideoMuted) {
|
|
|
|
dispatch(setStartMutedPolicy(
|
|
|
|
newState.startAudioMuted, newState.startVideoMuted));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-06-20 20:19:53 +00:00
|
|
|
/**
|
|
|
|
* Submits the settings from the "Profile" tab of the settings dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} newState - The new settings.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function submitProfileTab(newState: any) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2018-06-20 20:19:53 +00:00
|
|
|
const currentState = getProfileTabProps(getState());
|
|
|
|
|
|
|
|
if (newState.displayName !== currentState.displayName) {
|
|
|
|
APP.conference.changeLocalDisplayName(newState.displayName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.email !== currentState.email) {
|
|
|
|
APP.conference.changeLocalEmail(newState.email);
|
|
|
|
}
|
2023-03-03 08:42:59 +00:00
|
|
|
|
|
|
|
if (newState.hideSelfView !== currentState.hideSelfView) {
|
|
|
|
dispatch(updateSettings({ disableSelfView: newState.hideSelfView }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newState.currentLanguage !== currentState.currentLanguage) {
|
|
|
|
i18next.changeLanguage(newState.currentLanguage);
|
|
|
|
}
|
2018-06-20 20:19:53 +00:00
|
|
|
};
|
|
|
|
}
|
2020-03-30 14:17:18 +00:00
|
|
|
|
2021-07-20 11:56:57 +00:00
|
|
|
/**
|
|
|
|
* Submits the settings from the "Sounds" tab of the settings dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} newState - The new settings.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2023-03-03 10:53:39 +00:00
|
|
|
export function submitNotificationsTab(newState: any) {
|
2022-10-21 07:33:10 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2023-03-03 10:53:39 +00:00
|
|
|
const currentState = getNotificationsTabProps(getState());
|
2021-11-10 11:19:40 +00:00
|
|
|
const shouldNotUpdateReactionSounds = getModeratorTabProps(getState()).startReactionsMuted;
|
2021-07-20 11:56:57 +00:00
|
|
|
const shouldUpdate = (newState.soundsIncomingMessage !== currentState.soundsIncomingMessage)
|
|
|
|
|| (newState.soundsParticipantJoined !== currentState.soundsParticipantJoined)
|
2022-06-15 18:36:26 +00:00
|
|
|
|| (newState.soundsParticipantKnocking !== currentState.soundsParticipantKnocking)
|
2021-07-20 11:56:57 +00:00
|
|
|
|| (newState.soundsParticipantLeft !== currentState.soundsParticipantLeft)
|
2021-08-23 09:57:56 +00:00
|
|
|
|| (newState.soundsTalkWhileMuted !== currentState.soundsTalkWhileMuted)
|
|
|
|
|| (newState.soundsReactions !== currentState.soundsReactions);
|
2021-07-20 11:56:57 +00:00
|
|
|
|
|
|
|
if (shouldUpdate) {
|
2021-11-10 11:19:40 +00:00
|
|
|
const settingsToUpdate = {
|
2021-07-20 11:56:57 +00:00
|
|
|
soundsIncomingMessage: newState.soundsIncomingMessage,
|
|
|
|
soundsParticipantJoined: newState.soundsParticipantJoined,
|
2022-06-15 18:36:26 +00:00
|
|
|
soundsParticipantKnocking: newState.soundsParticipantKnocking,
|
2021-07-20 11:56:57 +00:00
|
|
|
soundsParticipantLeft: newState.soundsParticipantLeft,
|
2021-08-23 09:57:56 +00:00
|
|
|
soundsTalkWhileMuted: newState.soundsTalkWhileMuted,
|
|
|
|
soundsReactions: newState.soundsReactions
|
2021-11-10 11:19:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (shouldNotUpdateReactionSounds) {
|
|
|
|
delete settingsToUpdate.soundsReactions;
|
|
|
|
}
|
|
|
|
dispatch(updateSettings(settingsToUpdate));
|
2021-07-20 11:56:57 +00:00
|
|
|
}
|
2023-03-03 10:53:39 +00:00
|
|
|
|
|
|
|
const enabledNotifications = newState.enabledNotifications;
|
|
|
|
|
|
|
|
if (enabledNotifications !== currentState.enabledNotifications) {
|
|
|
|
dispatch(updateSettings({
|
|
|
|
userSelectedNotifications: {
|
|
|
|
...getState()['features/base/settings'].userSelectedNotifications,
|
|
|
|
...enabledNotifications
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
2021-07-20 11:56:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Toggles the visibility of the audio settings.
|
2020-03-30 14:17:18 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function toggleAudioSettings() {
|
2022-10-21 07:33:10 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2020-03-30 14:17:18 +00:00
|
|
|
const value = getState()['features/settings'].audioSettingsVisible;
|
|
|
|
|
|
|
|
dispatch(setAudioSettingsVisibility(!value));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Toggles the visibility of the video settings.
|
2020-03-30 14:17:18 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function toggleVideoSettings() {
|
2022-10-21 07:33:10 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2020-03-30 14:17:18 +00:00
|
|
|
const value = getState()['features/settings'].videoSettingsVisible;
|
|
|
|
|
|
|
|
dispatch(setVideoSettingsVisibility(!value));
|
|
|
|
};
|
|
|
|
}
|
2023-03-03 11:48:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Submits the settings from the "Shortcuts" tab of the settings dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} newState - The new settings.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function submitShortcutsTab(newState: any) {
|
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
|
|
|
const currentState = getShortcutsTabProps(getState());
|
|
|
|
|
|
|
|
if (newState.keyboardShortcutsEnabled !== currentState.keyboardShortcutsEnabled) {
|
|
|
|
keyboardShortcut.enable(newState.keyboardShortcutsEnabled);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|