Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

actions.web.ts 3.0KB

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