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.3KB

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