Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

actions.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // @flow
  2. import { setFollowMe, setStartMutedPolicy } from '../base/conference';
  3. import { openDialog } from '../base/dialog';
  4. import { i18next } from '../base/i18n';
  5. import { SET_SETTINGS_VIEW_VISIBLE } from './actionTypes';
  6. import { SettingsDialog } from './components';
  7. import { getMoreTabProps, getProfileTabProps } from './functions';
  8. declare var APP: Object;
  9. /**
  10. * Sets the visibility of the view/UI which renders the app's settings.
  11. *
  12. * @param {boolean} visible - If the view/UI which renders the app's settings is
  13. * to be made visible, {@code true}; otherwise, {@code false}.
  14. * @returns {{
  15. * type: SET_SETTINGS_VIEW_VISIBLE,
  16. * visible: boolean
  17. * }}
  18. */
  19. export function setSettingsViewVisible(visible: boolean) {
  20. return {
  21. type: SET_SETTINGS_VIEW_VISIBLE,
  22. visible
  23. };
  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. * Submits the settings from the "More" tab of the settings dialog.
  37. *
  38. * @param {Object} newState - The new settings.
  39. * @returns {Function}
  40. */
  41. export function submitMoreTab(newState: Object): Function {
  42. return (dispatch, getState) => {
  43. const currentState = getMoreTabProps(getState());
  44. if (newState.followMeEnabled !== currentState.followMeEnabled) {
  45. dispatch(setFollowMe(newState.followMeEnabled));
  46. }
  47. if (newState.startAudioMuted !== currentState.startAudioMuted
  48. || newState.startVideoMuted !== currentState.startVideoMuted) {
  49. dispatch(setStartMutedPolicy(
  50. newState.startAudioMuted, newState.startVideoMuted));
  51. }
  52. if (newState.currentLanguage !== currentState.currentLanguage) {
  53. i18next.changeLanguage(newState.currentLanguage);
  54. }
  55. };
  56. }
  57. /**
  58. * Submits the settings from the "Profile" tab of the settings dialog.
  59. *
  60. * @param {Object} newState - The new settings.
  61. * @returns {Function}
  62. */
  63. export function submitProfileTab(newState: Object): Function {
  64. return (dispatch, getState) => {
  65. const currentState = getProfileTabProps(getState());
  66. if (newState.displayName !== currentState.displayName) {
  67. APP.conference.changeLocalDisplayName(newState.displayName);
  68. }
  69. if (newState.email !== currentState.email) {
  70. APP.conference.changeLocalEmail(newState.email);
  71. }
  72. };
  73. }