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.native.ts 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { IStore } from '../app/types';
  2. import { hideDialog, openDialog } from '../base/dialog/actions';
  3. import AlertDialog from '../base/dialog/components/native/AlertDialog';
  4. import { getParticipantDisplayName } from '../base/participants/functions';
  5. import { DISMISS_CALENDAR_NOTIFICATION } from './actionTypes';
  6. /**
  7. * Notify that we've been kicked out of the conference.
  8. *
  9. * @param {JitsiParticipant} participant - The {@link JitsiParticipant}
  10. * instance which initiated the kick event.
  11. * @param {?Function} submit - The function to execute after submitting the dialog.
  12. * @returns {Function}
  13. */
  14. export function notifyKickedOut(participant: any, submit?: Function) {
  15. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  16. if (participant?.isReplaced?.()) {
  17. submit?.();
  18. return;
  19. }
  20. dispatch(openDialog(AlertDialog, {
  21. contentKey: {
  22. key: participant ? 'dialog.kickTitle' : 'dialog.kickSystemTitle',
  23. params: {
  24. participantDisplayName: participant && getParticipantDisplayName(getState, participant.getId())
  25. }
  26. },
  27. onSubmit: submit
  28. }));
  29. };
  30. }
  31. /**
  32. * Notify that we've been kicked out of the conference.
  33. *
  34. * @param {string} reasonKey - The translation key for the reason why the conference failed.
  35. * @param {?Function} submit - The function to execute after submitting the dialog.
  36. * @returns {Function}
  37. */
  38. export function notifyConferenceFailed(reasonKey: string, submit?: Function) {
  39. return (dispatch: IStore['dispatch']) => {
  40. if (!reasonKey) {
  41. submit?.();
  42. return;
  43. }
  44. // we have to push the opening of the dialog to the queue
  45. // so that we make sure it will be visible after the events
  46. // of conference destroyed are done
  47. setTimeout(() => dispatch(openDialog(AlertDialog, {
  48. contentKey: {
  49. key: reasonKey
  50. },
  51. params: {
  52. },
  53. onSubmit: () => {
  54. submit?.();
  55. dispatch(hideDialog(AlertDialog));
  56. }
  57. })));
  58. };
  59. }
  60. /**
  61. * Dismisses calendar notification about next or ongoing event.
  62. *
  63. * @returns {Object}
  64. */
  65. export function dismissCalendarNotification() {
  66. return {
  67. type: DISMISS_CALENDAR_NOTIFICATION
  68. };
  69. }