2018-02-08 18:50:19 +00:00
|
|
|
// @flow
|
2018-04-16 02:04:57 +00:00
|
|
|
|
2018-02-14 16:50:48 +00:00
|
|
|
import {
|
2018-04-16 02:04:57 +00:00
|
|
|
SET_CALENDAR_AUTHORIZATION,
|
|
|
|
SET_CALENDAR_EVENTS,
|
|
|
|
ADD_KNOWN_DOMAIN,
|
|
|
|
REFRESH_CALENDAR
|
2018-02-14 16:50:48 +00:00
|
|
|
} from './actionTypes';
|
2018-02-08 18:50:19 +00:00
|
|
|
|
2018-03-20 13:51:51 +00:00
|
|
|
/**
|
2018-04-16 02:04:57 +00:00
|
|
|
* Sends an action to add a new known domain if not present yet.
|
2018-03-20 13:51:51 +00:00
|
|
|
*
|
2018-04-16 02:04:57 +00:00
|
|
|
* @param {string} knownDomain - The new domain.
|
2018-03-20 13:51:51 +00:00
|
|
|
* @returns {{
|
2018-04-16 02:04:57 +00:00
|
|
|
* type: ADD_KNOWN_DOMAIN,
|
|
|
|
* knownDomain: string
|
2018-03-20 13:51:51 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-04-16 02:04:57 +00:00
|
|
|
export function addKnownDomain(knownDomain: string) {
|
2018-03-20 13:51:51 +00:00
|
|
|
return {
|
2018-04-16 02:04:57 +00:00
|
|
|
type: ADD_KNOWN_DOMAIN,
|
|
|
|
knownDomain
|
2018-03-20 13:51:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-08 18:50:19 +00:00
|
|
|
/**
|
2018-04-16 02:04:57 +00:00
|
|
|
* Sends an action to refresh the entry list (fetches new data).
|
2018-02-08 18:50:19 +00:00
|
|
|
*
|
2018-04-16 02:04:57 +00:00
|
|
|
* @param {boolean|undefined} forcePermission - Whether to force to re-ask for
|
|
|
|
* the permission or not.
|
2018-02-08 18:50:19 +00:00
|
|
|
* @returns {{
|
2018-04-16 02:04:57 +00:00
|
|
|
* type: REFRESH_CALENDAR,
|
|
|
|
* forcePermission: boolean
|
2018-02-08 18:50:19 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-04-16 02:04:57 +00:00
|
|
|
export function refreshCalendar(forcePermission: boolean = false) {
|
2018-02-08 18:50:19 +00:00
|
|
|
return {
|
2018-04-16 02:04:57 +00:00
|
|
|
type: REFRESH_CALENDAR,
|
|
|
|
forcePermission
|
2018-02-08 18:50:19 +00:00
|
|
|
};
|
|
|
|
}
|
2018-02-14 16:21:52 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-16 02:04:57 +00:00
|
|
|
* Sends an action to signal that a calendar access has been requested. For more
|
|
|
|
* info, see {@link SET_CALENDAR_AUTHORIZATION}.
|
2018-02-14 16:21:52 +00:00
|
|
|
*
|
2018-04-16 02:04:57 +00:00
|
|
|
* @param {string | undefined} authorization - The result of the last calendar
|
|
|
|
* authorization request.
|
2018-02-14 16:21:52 +00:00
|
|
|
* @returns {{
|
2018-04-16 02:04:57 +00:00
|
|
|
* type: SET_CALENDAR_AUTHORIZATION,
|
|
|
|
* authorization: ?string
|
2018-02-14 16:21:52 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-04-16 02:04:57 +00:00
|
|
|
export function setCalendarAuthorization(authorization: ?string) {
|
2018-02-14 16:21:52 +00:00
|
|
|
return {
|
2018-04-16 02:04:57 +00:00
|
|
|
type: SET_CALENDAR_AUTHORIZATION,
|
|
|
|
authorization
|
2018-02-14 16:50:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends an action to update the current calendar list in redux.
|
|
|
|
*
|
|
|
|
* @param {Array<Object>} events - The new list.
|
|
|
|
* @returns {{
|
2018-04-16 02:04:57 +00:00
|
|
|
* type: SET_CALENDAR_EVENTS,
|
|
|
|
* events: Array<Object>
|
2018-02-14 16:50:48 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-04-16 02:04:57 +00:00
|
|
|
export function setCalendarEvents(events: Array<Object>) {
|
2018-02-14 16:50:48 +00:00
|
|
|
return {
|
2018-04-16 02:04:57 +00:00
|
|
|
type: SET_CALENDAR_EVENTS,
|
2018-02-14 16:50:48 +00:00
|
|
|
events
|
2018-02-14 16:21:52 +00:00
|
|
|
};
|
|
|
|
}
|