您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 4.2KB

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