Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

actions.js 5.5KB

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