Up until now we relied on implicit loading of middlewares and reducers, through having imports in each feature's index.js. This leads to many complex import cycles which result in (sometimes) hard to fix bugs in addition to (often) breaking mobile because a web-only feature gets imported on mobile too, thanks to the implicit loading. This PR changes that to make the process explicit. Both middlewares and reducers are imported in a single place, the app entrypoint. They have been divided into 3 categories: any, web and native, which represent each of the platforms respectively. Ideally no feature should have an index.js exporting actions, action types and components, but that's a larger ordeal, so this is just the first step in getting there. In order to both set example and avoid large cycles the app feature has been refactored to not have an idex.js itself.
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
// @flow
|
|
import { generateRoomWithoutSeparator } from 'js-utils/random';
|
|
import type { Dispatch } from 'redux';
|
|
|
|
import { getDefaultURL } from '../app/functions';
|
|
import { openDialog } from '../base/dialog';
|
|
|
|
import { refreshCalendar } from './actions';
|
|
import {
|
|
UpdateCalendarEventDialog
|
|
} from './components';
|
|
import { addLinkToCalendarEntry } from './functions.native';
|
|
|
|
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) {
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
const defaultUrl = getDefaultURL(getState);
|
|
const roomName = generateRoomWithoutSeparator();
|
|
|
|
addLinkToCalendarEntry(getState(), eventId, `${defaultUrl}/${roomName}`)
|
|
.finally(() => {
|
|
dispatch(refreshCalendar(false, false));
|
|
});
|
|
};
|
|
}
|