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.web.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { IStore } from '../app/types';
  2. import { configureInitialDevices } from '../base/devices/actions.web';
  3. import { getParticipantDisplayName } from '../base/participants/functions';
  4. import { getBackendSafeRoomName } from '../base/util/uri';
  5. import { showNotification } from '../notifications/actions';
  6. import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../notifications/constants';
  7. import { DISMISS_CALENDAR_NOTIFICATION } from './actionTypes';
  8. import logger from './logger';
  9. /**
  10. * Notify that we've been kicked out of the conference.
  11. *
  12. * @param {JitsiParticipant} participant - The {@link JitsiParticipant}
  13. * instance which initiated the kick event.
  14. * @param {?Function} _ - Used only in native code.
  15. * @returns {Function}
  16. */
  17. export function notifyKickedOut(participant: any, _?: Function) {
  18. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  19. if (!participant || participant?.isReplaced()) {
  20. return;
  21. }
  22. const args = {
  23. participantDisplayName:
  24. getParticipantDisplayName(getState, participant.getId())
  25. };
  26. dispatch(showNotification({
  27. appearance: NOTIFICATION_TYPE.ERROR,
  28. hideErrorSupportLink: true,
  29. descriptionKey: 'dialog.kickMessage',
  30. descriptionArguments: args,
  31. titleKey: 'dialog.kickTitle',
  32. titleArguments: args
  33. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  34. };
  35. }
  36. /**
  37. * Dismisses calendar notification about next or ongoing event.
  38. *
  39. * @returns {Object}
  40. */
  41. export function dismissCalendarNotification() {
  42. return {
  43. type: DISMISS_CALENDAR_NOTIFICATION
  44. };
  45. }
  46. /**
  47. * Init.
  48. *
  49. * @returns {Promise<JitsiConnection>}
  50. */
  51. export function init() {
  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(configureInitialDevices()).then(
  57. () => APP.conference.init({
  58. roomName: room
  59. }).catch((error: Error) => {
  60. APP.API.notifyConferenceLeft(APP.conference.roomName);
  61. logger.error(error);
  62. }));
  63. };
  64. }