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 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // @ts-expect-error
  2. import { generateRoomWithoutSeparator } from '@jitsi/js-utils/random';
  3. import { getDefaultURL } from '../app/functions';
  4. import { IStore } from '../app/types';
  5. import { openDialog } from '../base/dialog/actions';
  6. import { refreshCalendar } from './actions';
  7. import UpdateCalendarEventDialog from './components/UpdateCalendarEventDialog.native';
  8. import { addLinkToCalendarEntry } from './functions.native';
  9. export * from './actions.any';
  10. /**
  11. * Asks confirmation from the user to add a Jitsi link to the calendar event.
  12. *
  13. * @param {string} eventId - The event id.
  14. * @returns {{
  15. * type: OPEN_DIALOG,
  16. * component: React.Component,
  17. * componentProps: (Object | undefined)
  18. * }}
  19. */
  20. export function openUpdateCalendarEventDialog(eventId: string) {
  21. return openDialog(UpdateCalendarEventDialog, { eventId });
  22. }
  23. /**
  24. * Updates calendar event by generating new invite URL and editing the event
  25. * adding some descriptive text and location.
  26. *
  27. * @param {string} eventId - The event id.
  28. * @returns {Function}
  29. */
  30. export function updateCalendarEvent(eventId: string) {
  31. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  32. const defaultUrl = getDefaultURL(getState);
  33. const roomName = generateRoomWithoutSeparator();
  34. addLinkToCalendarEntry(getState(), eventId, `${defaultUrl}/${roomName}`)
  35. .finally(() => {
  36. dispatch(refreshCalendar(false, false));
  37. });
  38. };
  39. }