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

actions.web.ts 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { IStore } from '../app/types';
  2. import { configureInitialDevices, getAvailableDevices } from '../base/devices/actions.web';
  3. import { openDialog } from '../base/dialog/actions';
  4. import { getBackendSafeRoomName } from '../base/util/uri';
  5. import { DISMISS_CALENDAR_NOTIFICATION } from './actionTypes';
  6. import LeaveReasonDialog from './components/web/LeaveReasonDialog.web';
  7. import logger from './logger';
  8. /**
  9. * Opens {@code LeaveReasonDialog}.
  10. *
  11. * @param {string} [title] - The dialog title.
  12. *
  13. * @returns {Promise} Resolved when the dialog is closed.
  14. */
  15. export function openLeaveReasonDialog(title?: string) {
  16. return (dispatch: IStore['dispatch']): Promise<void> => new Promise(resolve => {
  17. dispatch(openDialog(LeaveReasonDialog, {
  18. onClose: resolve,
  19. title
  20. }));
  21. });
  22. }
  23. /**
  24. * Dismisses calendar notification about next or ongoing event.
  25. *
  26. * @returns {Object}
  27. */
  28. export function dismissCalendarNotification() {
  29. return {
  30. type: DISMISS_CALENDAR_NOTIFICATION
  31. };
  32. }
  33. /**
  34. * Setups initial devices. Makes sure we populate availableDevices list before configuring.
  35. *
  36. * @returns {Promise<any>}
  37. */
  38. export function setupInitialDevices() {
  39. return async (dispatch: IStore['dispatch']) => {
  40. await dispatch(getAvailableDevices());
  41. await dispatch(configureInitialDevices());
  42. };
  43. }
  44. /**
  45. * Init.
  46. *
  47. * @param {boolean} shouldDispatchConnect - Whether or not connect should be dispatched. This should be false only when
  48. * prejoin is enabled.
  49. * @returns {Promise<JitsiConnection>}
  50. */
  51. export function init(shouldDispatchConnect: boolean) {
  52. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  53. const room = getBackendSafeRoomName(getState()['features/base/conference'].room);
  54. // XXX For web based version we use conference initialization logic
  55. // from the old app (at the moment of writing).
  56. return dispatch(setupInitialDevices()).then(
  57. () => APP.conference.init({
  58. roomName: room,
  59. shouldDispatchConnect
  60. }).catch((error: Error) => {
  61. APP.API.notifyConferenceLeft(APP.conference.roomName);
  62. logger.error(error);
  63. }));
  64. };
  65. }