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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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_SETTINGS_VIEW_VISIBLE,
  8. SET_VIDEO_SETTINGS_VISIBILITY
  9. } from './actionTypes';
  10. import { SettingsDialog } from './components';
  11. import { getMoreTabProps, getProfileTabProps } from './functions';
  12. declare var APP: Object;
  13. /**
  14. * Sets the visibility of the view/UI which renders the app's settings.
  15. *
  16. * @param {boolean} visible - If the view/UI which renders the app's settings is
  17. * to be made visible, {@code true}; otherwise, {@code false}.
  18. * @returns {{
  19. * type: SET_SETTINGS_VIEW_VISIBLE,
  20. * visible: boolean
  21. * }}
  22. */
  23. export function setSettingsViewVisible(visible: boolean) {
  24. return {
  25. type: SET_SETTINGS_VIEW_VISIBLE,
  26. visible
  27. };
  28. }
  29. /**
  30. * Opens {@code SettingsDialog}.
  31. *
  32. * @param {string} defaultTab - The tab in {@code SettingsDialog} that should be
  33. * displayed initially.
  34. * @returns {Function}
  35. */
  36. export function openSettingsDialog(defaultTab: string) {
  37. return openDialog(SettingsDialog, { defaultTab });
  38. }
  39. /**
  40. * Sets the visiblity of the audio settings.
  41. *
  42. * @param {boolean} value - The new value.
  43. * @returns {Function}
  44. */
  45. function setAudioSettingsVisibility(value: boolean) {
  46. return {
  47. type: SET_AUDIO_SETTINGS_VISIBILITY,
  48. value
  49. };
  50. }
  51. /**
  52. * Sets the visiblity of the video settings.
  53. *
  54. * @param {boolean} value - The new value.
  55. * @returns {Function}
  56. */
  57. function setVideoSettingsVisibility(value: boolean) {
  58. return {
  59. type: SET_VIDEO_SETTINGS_VISIBILITY,
  60. value
  61. };
  62. }
  63. /**
  64. * Submits the settings from the "More" tab of the settings dialog.
  65. *
  66. * @param {Object} newState - The new settings.
  67. * @returns {Function}
  68. */
  69. export function submitMoreTab(newState: Object): Function {
  70. return (dispatch, getState) => {
  71. const currentState = getMoreTabProps(getState());
  72. if (newState.followMeEnabled !== currentState.followMeEnabled) {
  73. dispatch(setFollowMe(newState.followMeEnabled));
  74. }
  75. if (newState.startAudioMuted !== currentState.startAudioMuted
  76. || newState.startVideoMuted !== currentState.startVideoMuted) {
  77. dispatch(setStartMutedPolicy(
  78. newState.startAudioMuted, newState.startVideoMuted));
  79. }
  80. if (newState.currentLanguage !== currentState.currentLanguage) {
  81. i18next.changeLanguage(newState.currentLanguage);
  82. }
  83. };
  84. }
  85. /**
  86. * Submits the settings from the "Profile" tab of the settings dialog.
  87. *
  88. * @param {Object} newState - The new settings.
  89. * @returns {Function}
  90. */
  91. export function submitProfileTab(newState: Object): Function {
  92. return (dispatch, getState) => {
  93. const currentState = getProfileTabProps(getState());
  94. if (newState.displayName !== currentState.displayName) {
  95. APP.conference.changeLocalDisplayName(newState.displayName);
  96. }
  97. if (newState.email !== currentState.email) {
  98. APP.conference.changeLocalEmail(newState.email);
  99. }
  100. };
  101. }
  102. /**
  103. * Toggles the visiblity of the audio settings.
  104. *
  105. * @returns {void}
  106. */
  107. export function toggleAudioSettings() {
  108. return (dispatch: Function, getState: Function) => {
  109. const value = getState()['features/settings'].audioSettingsVisible;
  110. dispatch(setAudioSettingsVisibility(!value));
  111. };
  112. }
  113. /**
  114. * Toggles the visiblity of the video settings.
  115. *
  116. * @returns {void}
  117. */
  118. export function toggleVideoSettings() {
  119. return (dispatch: Function, getState: Function) => {
  120. const value = getState()['features/settings'].videoSettingsVisible;
  121. dispatch(setVideoSettingsVisibility(!value));
  122. };
  123. }