2018-09-04 07:29:48 +00:00
|
|
|
// @flow
|
2019-03-19 17:35:36 +00:00
|
|
|
import { generateRoomWithoutSeparator } from 'js-utils/random';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2020-06-04 14:09:13 +00:00
|
|
|
import { getDefaultURL } from '../app/functions';
|
2018-09-04 07:29:48 +00:00
|
|
|
import { openDialog } from '../base/dialog';
|
|
|
|
|
|
|
|
import { refreshCalendar } from './actions';
|
|
|
|
import {
|
|
|
|
UpdateCalendarEventDialog
|
|
|
|
} from './components';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { addLinkToCalendarEntry } from './functions.native';
|
2018-09-04 07:29:48 +00:00
|
|
|
|
|
|
|
export * from './actions.any';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks confirmation from the user to add a Jitsi link to the calendar event.
|
|
|
|
*
|
|
|
|
* @param {string} eventId - The event id.
|
|
|
|
* @returns {{
|
|
|
|
* type: OPEN_DIALOG,
|
|
|
|
* component: React.Component,
|
|
|
|
* componentProps: (Object | undefined)
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function openUpdateCalendarEventDialog(eventId: string) {
|
|
|
|
return openDialog(UpdateCalendarEventDialog, { eventId });
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates calendar event by generating new invite URL and editing the event
|
|
|
|
* adding some descriptive text and location.
|
|
|
|
*
|
|
|
|
* @param {string} eventId - The event id.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function updateCalendarEvent(eventId: string) {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
2018-09-04 07:29:48 +00:00
|
|
|
const defaultUrl = getDefaultURL(getState);
|
|
|
|
const roomName = generateRoomWithoutSeparator();
|
|
|
|
|
|
|
|
addLinkToCalendarEntry(getState(), eventId, `${defaultUrl}/${roomName}`)
|
|
|
|
.finally(() => {
|
|
|
|
dispatch(refreshCalendar(false, false));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|