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

actions.js 3.2KB

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