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.

actions.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // @flow
  2. import { setFollowMe, setStartMutedPolicy } from '../base/conference';
  3. import { openDialog } from '../base/dialog';
  4. import { i18next } from '../base/i18n';
  5. import { updateSettings } from '../base/settings';
  6. import { setPrejoinPageVisibility } from '../prejoin/actions';
  7. import {
  8. SET_AUDIO_SETTINGS_VISIBILITY,
  9. SET_VIDEO_SETTINGS_VISIBILITY
  10. } from './actionTypes';
  11. import { SettingsDialog } from './components';
  12. import { getMoreTabProps, getProfileTabProps } from './functions';
  13. declare var APP: Object;
  14. /**
  15. * Opens {@code SettingsDialog}.
  16. *
  17. * @param {string} defaultTab - The tab in {@code SettingsDialog} that should be
  18. * displayed initially.
  19. * @returns {Function}
  20. */
  21. export function openSettingsDialog(defaultTab: string) {
  22. return openDialog(SettingsDialog, { defaultTab });
  23. }
  24. /**
  25. * Sets the visibility of the audio settings.
  26. *
  27. * @param {boolean} value - The new value.
  28. * @returns {Function}
  29. */
  30. function setAudioSettingsVisibility(value: boolean) {
  31. return {
  32. type: SET_AUDIO_SETTINGS_VISIBILITY,
  33. value
  34. };
  35. }
  36. /**
  37. * Sets the visibility of the video settings.
  38. *
  39. * @param {boolean} value - The new value.
  40. * @returns {Function}
  41. */
  42. function setVideoSettingsVisibility(value: boolean) {
  43. return {
  44. type: SET_VIDEO_SETTINGS_VISIBILITY,
  45. value
  46. };
  47. }
  48. /**
  49. * Submits the settings from the "More" tab of the settings dialog.
  50. *
  51. * @param {Object} newState - The new settings.
  52. * @returns {Function}
  53. */
  54. export function submitMoreTab(newState: Object): Function {
  55. return (dispatch, getState) => {
  56. const currentState = getMoreTabProps(getState());
  57. if (newState.followMeEnabled !== currentState.followMeEnabled) {
  58. dispatch(setFollowMe(newState.followMeEnabled));
  59. }
  60. const showPrejoinPage = newState.showPrejoinPage;
  61. if (showPrejoinPage !== currentState.showPrejoinPage) {
  62. // The 'showPrejoin' flag starts as 'true' on every new session.
  63. // This prevents displaying the prejoin page when the user re-enables it.
  64. if (showPrejoinPage && getState()['features/prejoin']?.showPrejoin) {
  65. dispatch(setPrejoinPageVisibility(false));
  66. }
  67. dispatch(updateSettings({
  68. userSelectedSkipPrejoin: !showPrejoinPage
  69. }));
  70. }
  71. if (newState.startAudioMuted !== currentState.startAudioMuted
  72. || newState.startVideoMuted !== currentState.startVideoMuted) {
  73. dispatch(setStartMutedPolicy(
  74. newState.startAudioMuted, newState.startVideoMuted));
  75. }
  76. if (newState.currentLanguage !== currentState.currentLanguage) {
  77. i18next.changeLanguage(newState.currentLanguage);
  78. }
  79. };
  80. }
  81. /**
  82. * Submits the settings from the "Profile" tab of the settings dialog.
  83. *
  84. * @param {Object} newState - The new settings.
  85. * @returns {Function}
  86. */
  87. export function submitProfileTab(newState: Object): Function {
  88. return (dispatch, getState) => {
  89. const currentState = getProfileTabProps(getState());
  90. if (newState.displayName !== currentState.displayName) {
  91. APP.conference.changeLocalDisplayName(newState.displayName);
  92. }
  93. if (newState.email !== currentState.email) {
  94. APP.conference.changeLocalEmail(newState.email);
  95. }
  96. };
  97. }
  98. /**
  99. * Toggles the visibility of the audio settings.
  100. *
  101. * @returns {void}
  102. */
  103. export function toggleAudioSettings() {
  104. return (dispatch: Function, getState: Function) => {
  105. const value = getState()['features/settings'].audioSettingsVisible;
  106. dispatch(setAudioSettingsVisibility(!value));
  107. };
  108. }
  109. /**
  110. * Toggles the visibility of the video settings.
  111. *
  112. * @returns {void}
  113. */
  114. export function toggleVideoSettings() {
  115. return (dispatch: Function, getState: Function) => {
  116. const value = getState()['features/settings'].videoSettingsVisible;
  117. dispatch(setVideoSettingsVisibility(!value));
  118. };
  119. }