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

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