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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import {
  3. SET_CALENDAR_AUTHORIZATION,
  4. SET_CALENDAR_EVENTS,
  5. ADD_KNOWN_DOMAIN,
  6. REFRESH_CALENDAR
  7. } from './actionTypes';
  8. /**
  9. * Sends an action to add a new known domain if not present yet.
  10. *
  11. * @param {string} knownDomain - The new domain.
  12. * @returns {{
  13. * type: ADD_KNOWN_DOMAIN,
  14. * knownDomain: string
  15. * }}
  16. */
  17. export function addKnownDomain(knownDomain: string) {
  18. return {
  19. type: ADD_KNOWN_DOMAIN,
  20. knownDomain
  21. };
  22. }
  23. /**
  24. * Sends an action to refresh the entry list (fetches new data).
  25. *
  26. * @param {boolean|undefined} forcePermission - Whether to force to re-ask for
  27. * the permission or not.
  28. * @returns {{
  29. * type: REFRESH_CALENDAR,
  30. * forcePermission: boolean
  31. * }}
  32. */
  33. export function refreshCalendar(forcePermission: boolean = false) {
  34. return {
  35. type: REFRESH_CALENDAR,
  36. forcePermission
  37. };
  38. }
  39. /**
  40. * Sends an action to signal that a calendar access has been requested. For more
  41. * info, see {@link SET_CALENDAR_AUTHORIZATION}.
  42. *
  43. * @param {string | undefined} authorization - The result of the last calendar
  44. * authorization request.
  45. * @returns {{
  46. * type: SET_CALENDAR_AUTHORIZATION,
  47. * authorization: ?string
  48. * }}
  49. */
  50. export function setCalendarAuthorization(authorization: ?string) {
  51. return {
  52. type: SET_CALENDAR_AUTHORIZATION,
  53. authorization
  54. };
  55. }
  56. /**
  57. * Sends an action to update the current calendar list in redux.
  58. *
  59. * @param {Array<Object>} events - The new list.
  60. * @returns {{
  61. * type: SET_CALENDAR_EVENTS,
  62. * events: Array<Object>
  63. * }}
  64. */
  65. export function setCalendarEvents(events: Array<Object>) {
  66. return {
  67. type: SET_CALENDAR_EVENTS,
  68. events
  69. };
  70. }