您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

googleCalendar.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. getCalendarEntries,
  5. googleApi,
  6. loadGoogleAPI,
  7. signIn,
  8. updateCalendarEvent,
  9. updateProfile
  10. } from '../../google-api';
  11. /**
  12. * A stateless collection of action creators that implements the expected
  13. * interface for interacting with the Google API in order to get calendar data.
  14. *
  15. * @type {Object}
  16. */
  17. export const googleCalendarApi = {
  18. /**
  19. * Retrieves the current calendar events.
  20. *
  21. * @param {number} fetchStartDays - The number of days to go back
  22. * when fetching.
  23. * @param {number} fetchEndDays - The number of days to fetch.
  24. * @returns {function(): Promise<CalendarEntries>}
  25. */
  26. getCalendarEntries,
  27. /**
  28. * Returns the email address for the currently logged in user.
  29. *
  30. * @returns {function(Dispatch<any>): Promise<string|never>}
  31. */
  32. getCurrentEmail() {
  33. return updateProfile();
  34. },
  35. /**
  36. * Initializes the google api if needed.
  37. *
  38. * @returns {function(Dispatch<any>, Function): Promise<void>}
  39. */
  40. load() {
  41. return (dispatch: Dispatch<any>) => dispatch(loadGoogleAPI());
  42. },
  43. /**
  44. * Prompts the participant to sign in to the Google API Client Library.
  45. *
  46. * @returns {function(Dispatch<any>): Promise<string|never>}
  47. */
  48. signIn,
  49. /**
  50. * Returns whether or not the user is currently signed in.
  51. *
  52. * @returns {function(): Promise<boolean>}
  53. */
  54. _isSignedIn() {
  55. return () => googleApi.isSignedIn();
  56. },
  57. /**
  58. * Updates calendar event by generating new invite URL and editing the event
  59. * adding some descriptive text and location.
  60. *
  61. * @param {string} id - The event id.
  62. * @param {string} calendarId - The id of the calendar to use.
  63. * @param {string} location - The location to save to the event.
  64. * @returns {function(Dispatch<any>): Promise<string|never>}
  65. */
  66. updateCalendarEvent
  67. };