@openeventkit/event-site 2.1.18 → 2.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/.github/workflows/jest.yml +1 -1
  2. package/babel.config.json +9 -9
  3. package/gatsby-node.js +67 -125
  4. package/jest.setup.js +2 -0
  5. package/netlify.toml +1 -1
  6. package/package.json +25 -16
  7. package/src/__mocks__/@mdx-js/mdx.js +32 -0
  8. package/src/__mocks__/@mdx-js/react.js +15 -0
  9. package/src/__mocks__/rehype-external-links.js +3 -0
  10. package/src/__mocks__/remark-gfm.js +3 -0
  11. package/src/actions/fetch-entities-actions.js +45 -87
  12. package/src/actions/update-data-actions.js +2 -2
  13. package/src/actions/user-actions.js +578 -430
  14. package/src/cms/config/collections/configurationsCollection/siteSettings/index.js +2 -0
  15. package/src/cms/config/collections/configurationsCollection/siteSettings/typeDefs.js +10 -0
  16. package/src/cms/preview-templates/ContentPagePreview.js +27 -29
  17. package/src/components/AvatarEditorModal/index.js +10 -0
  18. package/src/components/CertificatePDF.js +313 -0
  19. package/src/components/CertificateSection.js +139 -0
  20. package/src/components/FullSchedule.js +83 -66
  21. package/src/components/Mdx.js +39 -0
  22. package/src/components/__tests__/Mdx.test.jsx +70 -0
  23. package/src/content/site-settings/index.json +1 -1
  24. package/src/content/sponsors.json +1 -1
  25. package/src/i18n/locales/en.json +9 -1
  26. package/src/pages/a/[...].js +3 -0
  27. package/src/reducers/user-reducer.js +89 -27
  28. package/src/routes/authorization-callback-route.js +20 -2
  29. package/src/styles/rsvp-page.module.scss +63 -0
  30. package/src/templates/full-profile-page.js +61 -2
  31. package/src/templates/marketing-page-template/MainColumn.js +40 -42
  32. package/src/templates/rsvp-page.js +144 -0
  33. package/src/utils/alerts.js +1 -1
  34. package/src/utils/build-json/BaseAPIRequest.js +25 -0
  35. package/src/utils/build-json/EventsAPIRequest.js +171 -0
  36. package/src/utils/build-json/SpeakersAPIRequest.js +62 -0
  37. package/src/utils/build-json/SummitAPIRequest.js +115 -0
  38. package/src/utils/build-json/constants.js +5 -0
  39. package/src/utils/certificateSettings.js +45 -0
  40. package/src/utils/customErrorHandler.js +40 -1
  41. package/src/utils/rsvpConstants.js +7 -0
  42. package/src/utils/useMarketingSettings.js +48 -1
  43. package/src/utils/useSiteSettings.js +11 -0
  44. package/src/workers/feeds.worker.js +85 -90
  45. package/src/workers/sync_strategies/activity_synch_strategy.js +147 -102
  46. package/src/workers/sync_strategies/speaker_synch_strategy.js +3 -3
  47. package/src/workers/sync_strategies/track_synch_strategy.js +149 -48
  48. package/src/workers/synch.worker.js +123 -88
  49. package/static/fonts/fonts.css +120 -20
  50. package/static/fonts/nunito-sans/nunito-sans-v18-latin-200.woff2 +0 -0
  51. package/static/fonts/nunito-sans/nunito-sans-v18-latin-200italic.ttf +0 -0
  52. package/static/fonts/nunito-sans/nunito-sans-v18-latin-200italic.woff2 +0 -0
  53. package/static/fonts/nunito-sans/nunito-sans-v18-latin-300.woff2 +0 -0
  54. package/static/fonts/nunito-sans/nunito-sans-v18-latin-300italic.ttf +0 -0
  55. package/static/fonts/nunito-sans/nunito-sans-v18-latin-300italic.woff2 +0 -0
  56. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400.ttf +0 -0
  57. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400.woff2 +0 -0
  58. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400italic.ttf +0 -0
  59. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400italic.woff2 +0 -0
  60. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500.ttf +0 -0
  61. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500.woff2 +0 -0
  62. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500italic.ttf +0 -0
  63. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500italic.woff2 +0 -0
  64. package/static/fonts/nunito-sans/nunito-sans-v18-latin-600.woff2 +0 -0
  65. package/static/fonts/nunito-sans/nunito-sans-v18-latin-600italic.woff2 +0 -0
  66. package/static/fonts/nunito-sans/nunito-sans-v18-latin-700.ttf +0 -0
  67. package/static/fonts/nunito-sans/nunito-sans-v18-latin-700.woff2 +0 -0
  68. package/static/fonts/nunito-sans/nunito-sans-v18-latin-700italic.woff2 +0 -0
  69. package/static/fonts/nunito-sans/nunito-sans-v18-latin-800.ttf +0 -0
  70. package/static/fonts/nunito-sans/nunito-sans-v18-latin-800.woff2 +0 -0
  71. package/static/fonts/nunito-sans/nunito-sans-v18-latin-800italic.woff2 +0 -0
  72. package/static/fonts/nunito-sans/nunito-sans-v18-latin-900.ttf +0 -0
  73. package/static/fonts/nunito-sans/nunito-sans-v18-latin-900.woff2 +0 -0
  74. package/static/fonts/nunito-sans/nunito-sans-v18-latin-900italic.woff2 +0 -0
  75. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300.woff +0 -0
  76. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300.woff2 +0 -0
  77. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300italic.woff +0 -0
  78. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300italic.woff2 +0 -0
  79. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600.woff +0 -0
  80. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600.woff2 +0 -0
  81. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600italic.woff +0 -0
  82. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600italic.woff2 +0 -0
  83. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700.woff +0 -0
  84. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700.woff2 +0 -0
  85. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700italic.woff +0 -0
  86. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700italic.woff2 +0 -0
@@ -0,0 +1,62 @@
1
+ const BaseAPIRequest = require("./BaseAPIRequest");
2
+ class SpeakersAPIRequest extends BaseAPIRequest {
3
+ static instance;
4
+
5
+ constructor() {
6
+
7
+ const primary_fields =
8
+ ['id', 'first_name', 'last_name', 'title', 'bio', 'member_id', 'pic', 'big_pic', 'company'];
9
+
10
+ const badge_features_fields =
11
+ ['badge_features.id', 'badge_features.image', 'badge_features.name'];
12
+
13
+ const relations = [
14
+ 'badge_features',
15
+ 'presentations',
16
+ 'moderated_presentations',
17
+ ];
18
+
19
+ const expands = [
20
+ 'badge_features'
21
+ ];
22
+
23
+ super(
24
+ [
25
+ ...primary_fields,
26
+ ...badge_features_fields
27
+ ],
28
+ relations,
29
+ expands
30
+ );
31
+
32
+ if (!SpeakersAPIRequest.instance) {
33
+ SpeakersAPIRequest.instance = this;
34
+ }
35
+ }
36
+
37
+ static getInstance() {
38
+ if (!SpeakersAPIRequest.instance) {
39
+ new SpeakersAPIRequest();
40
+ }
41
+ return SpeakersAPIRequest.instance;
42
+ }
43
+
44
+ static getParams(apiUrl) {
45
+ const instance = SpeakersAPIRequest.getInstance();
46
+ apiUrl.addQuery("fields", instance.getFields());
47
+ apiUrl.addQuery("expand", instance.getExpands());
48
+ apiUrl.addQuery("relations", instance.getRelations());
49
+ return apiUrl.query(true);
50
+ }
51
+
52
+ static build(apiUrl) {
53
+ const instance = SpeakersAPIRequest.getInstance();
54
+ apiUrl.addQuery("fields", instance.getFields());
55
+ apiUrl.addQuery("expand", instance.getExpands());
56
+ apiUrl.addQuery("relations", instance.getRelations());
57
+
58
+ return apiUrl.toString();
59
+ }
60
+ }
61
+
62
+ module.exports = SpeakersAPIRequest;
@@ -0,0 +1,115 @@
1
+ const BaseAPIRequest = require("./BaseAPIRequest");
2
+
3
+ class SummitAPIRequest extends BaseAPIRequest {
4
+ static instance;
5
+
6
+ constructor() {
7
+ const primary_fields = [
8
+ "id", "name", "start_date", "end_date", "time_zone_id", "time_zone_label", "secondary_logo", "slug",
9
+ "support_email", "start_showing_venues_date", "dates_with_events", "logo",
10
+ "registration_allowed_refund_request_till_date", "allow_update_attendee_extra_questions", "is_virtual",
11
+ "registration_disclaimer_mandatory", "registration_disclaimer_content", "reassign_ticket_till_date",
12
+ "is_main", "title", "description", "time_zone"
13
+ ];
14
+
15
+ // TODO: to be reviewed later with data syncs actions to match the needs of the data update
16
+ const event_types_fields = [
17
+ "event_types.id"
18
+ ];
19
+
20
+ const tracks_fields = [
21
+ "tracks.id", "tracks.name", "tracks.code", "tracks.order", "tracks.parent_id", "tracks.color","tracks.text_color",
22
+ "tracks.subtracks.id", "tracks.subtracks.name", "tracks.subtracks.code", "tracks.subtracks.order",
23
+ "tracks.subtracks.parent_id", "tracks.subtracks.color","tracks.subtracks.text_color",
24
+ ];
25
+
26
+ const ticket_types_fields = [
27
+ "ticket_types.id", "ticket_types.name", "ticket_types.created", "ticket_types.cost"
28
+ ];
29
+
30
+ const track_groups_fields = [
31
+ "track_groups.id", "track_groups.name", "track_groups.color"
32
+ ];
33
+
34
+ const location_fields = [
35
+ "locations.id", "locations.class_name", "locations.is_main", "locations.name", "locations.city",
36
+ "locations.country", "locations.venue.name"
37
+ ];
38
+
39
+ const ticket_types_relations = ["ticket_types.none"];
40
+ const tracks_relations = ["tracks", "tracks.subtracks.none"];
41
+ const track_groups_relations = ["track_groups.none"];
42
+ const location_relations = ["locations.none, locations.venue.none"];
43
+ const event_types_relations = ["event_types.none"];
44
+
45
+ const relations = [
46
+ "dates_with_events",
47
+ "locations",
48
+ "payment_profiles",
49
+ "time_zone",
50
+ ...ticket_types_relations,
51
+ ...tracks_relations,
52
+ ...track_groups_relations,
53
+ ...location_relations,
54
+ ...event_types_relations
55
+ ];
56
+
57
+ const schedule_settings_expands = [
58
+ "schedule_settings.filters",
59
+ "schedule_settings.pre_filters"
60
+ ];
61
+
62
+ const track_expands = ["tracks.subtracks"];
63
+
64
+ const locations_expands = ["locations.venue"];
65
+
66
+ const expands = [
67
+ "event_types",
68
+ "badge_features_types",
69
+ "tracks",
70
+ "track_groups",
71
+ "presentation_levels",
72
+ "locations",
73
+ "schedule_settings",
74
+ "ticket_types",
75
+ ...schedule_settings_expands,
76
+ ...track_expands,
77
+ ...locations_expands
78
+ ];
79
+
80
+ super(
81
+ [
82
+ ...primary_fields,
83
+ ...event_types_fields,
84
+ ...tracks_fields,
85
+ ...ticket_types_fields,
86
+ ...track_groups_fields,
87
+ ...location_fields,
88
+ ],
89
+ relations,
90
+ expands
91
+ );
92
+
93
+ if (!SummitAPIRequest.instance) {
94
+ SummitAPIRequest.instance = this;
95
+ }
96
+ }
97
+
98
+ static getInstance() {
99
+ if (!SummitAPIRequest.instance) {
100
+ new SummitAPIRequest();
101
+ }
102
+ return SummitAPIRequest.instance;
103
+ }
104
+
105
+ static build = (apiUrl) => {
106
+ const instance = SummitAPIRequest.getInstance();
107
+ apiUrl.addQuery("fields", instance.getFields());
108
+ apiUrl.addQuery("expand", instance.getExpands());
109
+ apiUrl.addQuery("relations", instance.getRelations());
110
+
111
+ return apiUrl.toString();
112
+ }
113
+ }
114
+
115
+ module.exports = SummitAPIRequest;
@@ -0,0 +1,5 @@
1
+ const FIFTY_PER_PAGE = "50";
2
+
3
+ module.exports = {
4
+ FIFTY_PER_PAGE
5
+ };
@@ -0,0 +1,45 @@
1
+ import useMarketingSettings, { MARKETING_SETTINGS_KEYS, DISPLAY_OPTIONS } from './useMarketingSettings';
2
+
3
+ export const useCertificateSettings = (siteFont = null) => {
4
+ const { getSettingByKey } = useMarketingSettings();
5
+
6
+ const certificateKeys = {
7
+ // general summit keys
8
+ colorAccent: MARKETING_SETTINGS_KEYS.colorAccent,
9
+ colorPrimary: MARKETING_SETTINGS_KEYS.colorPrimary,
10
+ colorPrimaryContrast: MARKETING_SETTINGS_KEYS.colorPrimaryContrast,
11
+ colorSecondary: MARKETING_SETTINGS_KEYS.colorSecondary,
12
+ colorTextDark: MARKETING_SETTINGS_KEYS.colorTextDark,
13
+ colorTextLight: MARKETING_SETTINGS_KEYS.colorTextLight,
14
+ // certificate specific
15
+ enabled: MARKETING_SETTINGS_KEYS.certificateEnabled,
16
+ height: MARKETING_SETTINGS_KEYS.certificateHeight,
17
+ width: MARKETING_SETTINGS_KEYS.certificateWidth,
18
+ mainColor: MARKETING_SETTINGS_KEYS.certificateMainColor,
19
+ logo: MARKETING_SETTINGS_KEYS.certificateLogo,
20
+ logoWidth: MARKETING_SETTINGS_KEYS.certificateLogoWidth,
21
+ logoHeight: MARKETING_SETTINGS_KEYS.certificateLogoHeight,
22
+ titleText: MARKETING_SETTINGS_KEYS.certificateTitleText,
23
+ summitName: MARKETING_SETTINGS_KEYS.certificateSummitName,
24
+ showRole: MARKETING_SETTINGS_KEYS.certificateShowRole,
25
+ };
26
+
27
+ const certificateSettings = {};
28
+
29
+ Object.entries(certificateKeys).forEach(([propName, key]) => {
30
+ const value = getSettingByKey(key);
31
+ if (value !== undefined) {
32
+ certificateSettings[propName] = value;
33
+ }
34
+ });
35
+
36
+ certificateSettings.enabled = certificateSettings.enabled !== DISPLAY_OPTIONS.hide;
37
+ certificateSettings.showRole = certificateSettings.showRole !== DISPLAY_OPTIONS.hide;
38
+
39
+ // Pass through the site font information if available
40
+ if (siteFont) {
41
+ certificateSettings.siteFont = siteFont;
42
+ }
43
+
44
+ return certificateSettings;
45
+ };
@@ -1,6 +1,11 @@
1
1
  import expiredToken from './expiredToken';
2
- import { stopLoading } from "openstack-uicore-foundation/lib/utils/actions";
3
2
  import Swal from 'sweetalert2';
3
+ import {RSVP_INVITATION_ERROR} from "../actions/user-actions";
4
+ import {
5
+ createAction,
6
+ stopLoading,
7
+ } from 'openstack-uicore-foundation/lib/utils/actions';
8
+
4
9
 
5
10
  export const customErrorHandler = (err, res) => (dispatch, state) => {
6
11
  let code = err.status;
@@ -76,4 +81,38 @@ export const customBadgeHandler = (err, res) => (dispatch, state) => {
76
81
  default:
77
82
  break;
78
83
  }
84
+ }
85
+
86
+ export const customRSVPHandler = (err, res) => (dispatch, state) => {
87
+ let code = err.status;
88
+ dispatch(stopLoading());
89
+ let msg = '';
90
+ switch (code) {
91
+ case 401:
92
+ console.log('authErrorHandler 401 - re login');
93
+ expiredToken(err);
94
+ break;
95
+ case 404:
96
+ msg = "";
97
+
98
+ if (err.response.body && err.response.body.message) msg = err.response.body.message;
99
+ else if (err.response.error && err.response.error.message) msg = err.response.error.message;
100
+ else msg = err.message;
101
+
102
+ dispatch(createAction(RSVP_INVITATION_ERROR)({ errorMessage: msg }))
103
+ break;
104
+ case 412:
105
+ for (var [key, value] of Object.entries(err.response.body.errors)) {
106
+ if (isNaN(key)) {
107
+ msg += key + ': ';
108
+ }
109
+
110
+ msg += value + '<br>';
111
+ }
112
+ dispatch(createAction(RSVP_INVITATION_ERROR)({ errorMessage: msg }))
113
+ break;
114
+ default:
115
+ dispatch(createAction(RSVP_INVITATION_ERROR)({ errorMessage: "Internal Error. Please contact support " }))
116
+ break;
117
+ }
79
118
  }
@@ -0,0 +1,7 @@
1
+ const RSVP_STATUS = {
2
+ accepted: "Accepted",
3
+ pending: "Pending",
4
+ rejected: "Rejected"
5
+ };
6
+
7
+ export { RSVP_STATUS };
@@ -1,6 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { graphql, useStaticQuery } from "gatsby";
3
3
 
4
+ export const DISPLAY_OPTIONS = {
5
+ show: "SHOW",
6
+ hide: "HIDE"
7
+ };
8
+
4
9
  export const MARKETING_SETTINGS_KEYS = {
5
10
  disqusThreadsBy: "disqus_threads_by",
6
11
  disqusExcludeEvents: "disqus_exclude_events",
@@ -22,9 +27,51 @@ export const MARKETING_SETTINGS_KEYS = {
22
27
  regLiteOrderComplete2ndParagraph: "REG_LITE_ORDER_COMPLETE_STEP_2ND_PARAGRAPH",
23
28
  regLiteOrderCompleteButton: "REG_LITE_ORDER_COMPLETE_BTN_LABEL",
24
29
  regLiteNoAllowedTicketsMessage: "REG_LITE_NO_ALLOWED_TICKETS_MESSAGE",
30
+ // Color settings (from scssUtils/defaults)
31
+ colorAccent: "color_accent",
32
+ colorAlerts: "color_alerts",
33
+ colorBackgroundLight: "color_background_light",
34
+ colorBackgroundDark: "color_background_dark",
35
+ colorButtonBackgroundColor: "color_button_background_color",
36
+ colorButtonColor: "color_button_color",
37
+ colorGrayLighter: "color_gray_lighter",
38
+ colorGrayLight: "color_gray_light",
39
+ colorGrayDark: "color_gray_dark",
40
+ colorGrayDarker: "color_gray_darker",
41
+ colorHorizontalRuleLight: "color_horizontal_rule_light",
42
+ colorHorizontalRuleDark: "color_horizontal_rule_dark",
43
+ colorIconLight: "color_icon_light",
44
+ colorInputBackgroundColorLight: "color_input_background_color_light",
45
+ colorInputBackgroundColorDark: "color_input_background_color_dark",
46
+ colorInputBorderColorLight: "color_input_border_color_light",
47
+ colorInputBorderColorDark: "color_input_border_color_dark",
48
+ colorInputTextColorLight: "color_input_text_color_light",
49
+ colorInputTextColorDark: "color_input_text_color_dark",
50
+ colorInputTextColorDisabledLight: "color_input_text_color_disabled_light",
51
+ colorInputTextColorDisabledDark: "color_input_text_color_disabled_dark",
52
+ colorPrimary: "color_primary",
53
+ colorPrimaryContrast: "color_primary_contrast",
54
+ colorSecondary: "color_secondary",
55
+ colorSecondaryContrast: "color_secondary_contrast",
56
+ colorTextLight: "color_text_light",
57
+ colorTextMed: "color_text_med",
58
+ colorTextDark: "color_text_dark",
59
+ colorTextInputHintsLight: "color_text_input_hints_light",
60
+ colorTextInputHintsDark: "color_text_input_hints_dark",
61
+ colorTextInputHints: "color_text_input_hints",
62
+ // Certificate of Attendance settings
63
+ certificateEnabled: "CERTIFICATE_ENABLED",
64
+ certificateHeight: "CERTIFICATE_HEIGHT",
65
+ certificateWidth: "CERTIFICATE_WIDTH",
66
+ certificateMainColor: "CERTIFICATE_MAIN_COLOR",
67
+ certificateLogo: "CERTIFICATE_LOGO",
68
+ certificateLogoWidth: "CERTIFICATE_LOGO_WIDTH",
69
+ certificateLogoHeight: "CERTIFICATE_LOGO_HEIGHT",
70
+ certificateTitleText: "CERTIFICATE_TITLE_TEXT",
71
+ certificateSummitName: "CERTIFICATE_SUMMIT_NAME",
72
+ certificateShowRole: "CERTIFICATE_SHOW_ROLE",
25
73
  }
26
74
 
27
-
28
75
  const marketingSettingsQuery = graphql`
29
76
  query {
30
77
  allMarketingSettingsJson {
@@ -13,6 +13,17 @@ const siteSettingsQuery = graphql`
13
13
  publicURL
14
14
  }
15
15
  }
16
+ siteFont {
17
+ fontFamily
18
+ regularFont {
19
+ fontFile
20
+ fontFormat
21
+ }
22
+ boldFont {
23
+ fontFile
24
+ fontFormat
25
+ }
26
+ }
16
27
  widgets {
17
28
  chat {
18
29
  enabled
@@ -6,101 +6,96 @@ import speakersBuildJson from "data/speakers.json";
6
6
  import speakersIDXBuildJson from "data/speakers.idx.json";
7
7
 
8
8
  import {
9
- bucket_getSummit,
10
- bucket_getEvents,
11
- bucket_getEventsIDX,
12
- bucket_getSpeakers,
13
- bucket_getSpeakersIDX
9
+ bucket_getSummit,
10
+ bucket_getEvents,
11
+ bucket_getEventsIDX,
12
+ bucket_getSpeakers,
13
+ bucket_getSpeakersIDX
14
14
  } from "../actions/update-data-actions";
15
15
 
16
16
  import {
17
- SUMMIT_FILE_PATH,
18
- EVENTS_FILE_PATH,
19
- EVENTS_IDX_FILE_PATH,
20
- SPEAKERS_FILE_PATH,
21
- SPEAKERS_IDX_FILE_PATH
17
+ SUMMIT_FILE_PATH,
18
+ EVENTS_FILE_PATH,
19
+ EVENTS_IDX_FILE_PATH,
20
+ SPEAKERS_FILE_PATH,
21
+ SPEAKERS_IDX_FILE_PATH
22
22
  } from "../utils/filePath";
23
23
 
24
+ const isNonEmptyObject = (v) =>
25
+ v && typeof v === "object" && !Array.isArray(v) && Object.keys(v).length > 0;
26
+
27
+ const isNonEmptyArray = (v) => Array.isArray(v) && v.length > 0;
28
+
29
+ const pick = (result, expect) => {
30
+ if (!result || typeof result !== "object") {
31
+ return {accepted: false, data: null, lastModified: 0};
32
+ }
33
+ const {file, lastModified} = result;
34
+ const ok =
35
+ expect === "object" ? isNonEmptyObject(file) :
36
+ expect === "array" ? isNonEmptyArray(file) : false;
37
+
38
+ return ok
39
+ ? {accepted: true, data: file, lastModified: lastModified}
40
+ : {accepted: false, data: null, lastModified: 0};
41
+ };
42
+
24
43
  /* eslint-disable-next-line no-restricted-globals */
25
44
  self.onmessage = async ({data: {summitId, staticJsonFilesBuildTime}}) => {
26
- staticJsonFilesBuildTime = JSON.parse(staticJsonFilesBuildTime);
27
-
28
- console.log(`feeds worker running for ${summitId} ....`)
29
- const calls = [];
30
-
31
- // events
32
- let buildTime = staticJsonFilesBuildTime.find(e => e.file === EVENTS_FILE_PATH).build_time;
33
-
34
- calls.push(bucket_getEvents(summitId, buildTime));
35
-
36
- buildTime = staticJsonFilesBuildTime.find(e => e.file === EVENTS_IDX_FILE_PATH).build_time;
37
- calls.push(bucket_getEventsIDX(summitId, buildTime));
38
-
39
- // summit
40
- buildTime = staticJsonFilesBuildTime.find(e => e.file === SUMMIT_FILE_PATH).build_time;
41
- calls.push(bucket_getSummit(summitId, buildTime));
42
-
43
- //speakers
44
- buildTime = staticJsonFilesBuildTime.find(e => e.file === SPEAKERS_FILE_PATH).build_time;
45
- calls.push(bucket_getSpeakers(summitId, buildTime));
46
-
47
- buildTime = staticJsonFilesBuildTime.find(e => e.file === SPEAKERS_IDX_FILE_PATH).build_time;
48
- calls.push(bucket_getSpeakersIDX(summitId, buildTime));
49
-
50
- Promise.all(calls)
51
- .then((values) => {
52
- let lastModified = settings.lastBuild;
53
- let eventsData = values[0];
54
- let eventsIDXData = values[1];
55
- let summitData = values[2];
56
- let speakersData = values[3];
57
- let speakersIXData = values[4];
58
-
59
- // if null , then set the SSR content
60
- // summit
61
- if (summitData && summitData?.file){
62
- if(summitData.lastModified > lastModified)
63
- lastModified = summitData.lastModified;
64
- summitData = summitData.file;
65
- }
66
- else
67
- summitData = summitBuildJson;
68
- // events
69
- if (eventsData && eventsData?.file){
70
- if(eventsData.lastModified > lastModified)
71
- lastModified = eventsData.lastModified;
72
- eventsData = eventsData.file;
73
- }
74
- else
75
- eventsData = eventsBuildJson;
76
- // events idx
77
- if (eventsIDXData && eventsIDXData?.file){
78
- if(eventsIDXData.lastModified > lastModified)
79
- lastModified = eventsIDXData.lastModified;
80
- eventsIDXData = eventsIDXData.file;
81
- }
82
- else
83
- eventsIDXData = eventsIDXBuildJson;
84
- // speakers
85
- if (speakersData && speakersData?.file){
86
- if(speakersData.lastModified > lastModified)
87
- lastModified = speakersData.lastModified;
88
- speakersData = speakersData.file;
89
- }
90
- else
91
- speakersData = speakersBuildJson;
92
- // speakers idx
93
- if (speakersIXData && speakersIXData?.file){
94
- if(speakersIXData.lastModified > lastModified)
95
- lastModified = speakersIXData.lastModified;
96
- speakersIXData = speakersIXData.file;
97
- }
98
- else
99
- speakersIXData = speakersIDXBuildJson;
100
-
101
- /* eslint-disable-next-line no-restricted-globals */
102
- self.postMessage({
103
- eventsData, summitData, speakersData, eventsIDXData, speakersIXData, lastModified
104
- });
105
- });
45
+ staticJsonFilesBuildTime = JSON.parse(staticJsonFilesBuildTime);
46
+
47
+ console.log(`feeds worker running for ${summitId} ....`)
48
+ const calls = [];
49
+
50
+ // events
51
+ let buildTime = staticJsonFilesBuildTime.find(e => e.file === EVENTS_FILE_PATH).build_time;
52
+
53
+ calls.push(bucket_getEvents(summitId, buildTime));
54
+
55
+ buildTime = staticJsonFilesBuildTime.find(e => e.file === EVENTS_IDX_FILE_PATH).build_time;
56
+ calls.push(bucket_getEventsIDX(summitId, buildTime));
57
+
58
+ // summit
59
+ buildTime = staticJsonFilesBuildTime.find(e => e.file === SUMMIT_FILE_PATH).build_time;
60
+ calls.push(bucket_getSummit(summitId, buildTime));
61
+
62
+ //speakers
63
+ buildTime = staticJsonFilesBuildTime.find(e => e.file === SPEAKERS_FILE_PATH).build_time;
64
+ calls.push(bucket_getSpeakers(summitId, buildTime));
65
+
66
+ buildTime = staticJsonFilesBuildTime.find(e => e.file === SPEAKERS_IDX_FILE_PATH).build_time;
67
+ calls.push(bucket_getSpeakersIDX(summitId, buildTime));
68
+
69
+ Promise.all(calls)
70
+ .then((values) => {
71
+ let lastModified = settings.lastBuild;
72
+ let eventsData = values[0];
73
+ let eventsIDXData = values[1];
74
+ let summitData = values[2];
75
+ let speakersData = values[3];
76
+ let speakersIXData = values[4];
77
+
78
+ // if null , then set the SSR content
79
+ // summit
80
+ const summitDataPicked = pick(summitData, "object");
81
+ summitData = summitDataPicked.accepted && summitDataPicked.lastModified > lastModified ? summitDataPicked.data : summitBuildJson;
82
+ // events
83
+ const eventsDataPicked = pick(eventsData, "array");
84
+ eventsData = eventsDataPicked.accepted && eventsDataPicked.lastModified > lastModified ? eventsDataPicked.data : eventsBuildJson;
85
+ // events idx
86
+ const eventsIDXDataPicked = pick(eventsIDXData, "object");
87
+ eventsIDXData = eventsIDXDataPicked.accepted && eventsIDXDataPicked.lastModified > lastModified ? eventsIDXDataPicked.data : eventsIDXBuildJson;
88
+ // speakers
89
+ const speakersDataPicked = pick(speakersData, "array");
90
+ speakersData = speakersDataPicked.accepted && speakersDataPicked.lastModified > lastModified ? speakersDataPicked.data : speakersBuildJson;
91
+ // speakers idx
92
+ const speakersIXDataPicked = pick(speakersIXData, "object");
93
+ speakersIXData = speakersIXDataPicked.accepted && speakersIXDataPicked.lastModified > lastModified ? speakersIXDataPicked.data : speakersIDXBuildJson;
94
+
95
+
96
+ /* eslint-disable-next-line no-restricted-globals */
97
+ self.postMessage({
98
+ eventsData, summitData, speakersData, eventsIDXData, speakersIXData, lastModified
99
+ });
100
+ });
106
101
  };