jamespot-front-business 1.3.5 → 1.3.6

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.
package/dist/cjs.js CHANGED
@@ -1138,17 +1138,27 @@ const initialState$k = {
1138
1138
  types: [],
1139
1139
  pendingStatusChanges: [],
1140
1140
  };
1141
+ let fetchTimeout = null;
1142
+ const debounceFetch = (dispatch, params, delay = 500) => {
1143
+ if (fetchTimeout)
1144
+ clearTimeout(fetchTimeout);
1145
+ fetchTimeout = setTimeout(() => {
1146
+ dispatch(fetchEvents(params));
1147
+ }, delay);
1148
+ };
1141
1149
  const fetchEvents = toolkit.createAsyncThunk('calendarEvents/fetchEvents', async (params, { extra, rejectWithValue, dispatch, signal, getState }) => {
1142
1150
  const state = getState().calendar.events;
1143
1151
  if (!params.dates && !state.dates) {
1144
1152
  return rejectWithValue({ error: 1, errorMsg: 'Dates must be set' });
1145
1153
  }
1154
+ let types = params.types ?? state.types;
1155
+ types = types.includes('socialEvent') ? [...types, 'recurringEvent'] : [...types];
1146
1156
  try {
1147
1157
  const payload = {
1148
1158
  dateStart: params.dates?.start ?? state.dates?.start ?? '',
1149
1159
  dateEnd: params.dates?.end ?? state.dates?.end ?? '',
1150
1160
  statuses: state.statuses,
1151
- types: params.types ?? state.types,
1161
+ types,
1152
1162
  };
1153
1163
  const res = await extra.jApi.calendar.listEvents(payload, {
1154
1164
  format: 'raw-view',
@@ -1164,11 +1174,11 @@ const fetchEvents = toolkit.createAsyncThunk('calendarEvents/fetchEvents', async
1164
1174
  }
1165
1175
  });
1166
1176
  const setDates = toolkit.createAsyncThunk('calendarEvents/setDates', async (params, { dispatch }) => {
1167
- dispatch(fetchEvents({ dates: params }));
1177
+ debounceFetch(dispatch, { dates: params });
1168
1178
  return true;
1169
1179
  });
1170
1180
  const setTypes = toolkit.createAsyncThunk('calendarEvents/setTypes', async (params, { dispatch }) => {
1171
- dispatch(fetchEvents({ types: params }));
1181
+ debounceFetch(dispatch, { types: params });
1172
1182
  return true;
1173
1183
  });
1174
1184
  const changeResponse = toolkit.createAsyncThunk('calendarEvents/changeResponse', async (params, { dispatch, extra, signal, rejectWithValue }) => {
@@ -1267,19 +1277,33 @@ const CalendarEventsSlice = toolkit.createSlice({
1267
1277
  }
1268
1278
  state.pendingStatusChanges = state.pendingStatusChanges.filter((e) => e.requestId !== action.meta.requestId);
1269
1279
  }
1280
+ })
1281
+ .addCase(setDates.pending, (state, action) => {
1282
+ state.dates = { start: action.meta.arg.start, end: action.meta.arg.end };
1283
+ state.loading = 'pending';
1284
+ })
1285
+ .addCase(setTypes.pending, (state, action) => {
1286
+ state.types = action.meta.arg;
1287
+ state.loading = 'pending';
1270
1288
  });
1271
1289
  },
1272
1290
  });
1273
1291
 
1274
- const isCalendarEvent = (type) => ['socialEvent', 'meeting', 'animatedMeeting'].includes(type);
1292
+ const isCalendarEvent = (type) => ['socialEvent', 'meeting', 'animatedMeeting', 'recurringEvent', 'recurringEventOccurrence'].includes(type);
1275
1293
  const getCalendarRTHandlers = function (dispatch, jApi) {
1276
1294
  const addEventHandler = function (message) {
1277
1295
  if (message.namespace === 'JAMESPOT' &&
1278
1296
  message.function === 'article-create' &&
1279
1297
  isCalendarEvent(message.object.type)) {
1280
- jApi.article.get({ uri: message.object.uri }, { format: 'raw-view', formatExtension: ['socialEventRecord'] })
1298
+ if (message.object.type === 'recurringEvent') {
1299
+ dispatch(fetchEvents({}));
1300
+ return;
1301
+ }
1302
+ jApi.article.get({ uri: message.object.uri }, { format: 'raw-view', formatExtension: ['socialEventRecord', 'recurringEventRecord'] })
1281
1303
  .then((res) => {
1282
- dispatch(CalendarEventsSlice.actions.addEvent(res.result));
1304
+ if (!('hideFromCalendar' in res.result) || !res.result.hideFromCalendar) {
1305
+ dispatch(CalendarEventsSlice.actions.addEvent(res.result));
1306
+ }
1283
1307
  })
1284
1308
  .catch((e) => {
1285
1309
  dispatch(Toast.actions.error({ label: getErrorMessage(e) }));
@@ -1290,6 +1314,10 @@ const getCalendarRTHandlers = function (dispatch, jApi) {
1290
1314
  if (message.namespace === 'JAMESPOT' &&
1291
1315
  message.function === 'article-delete' &&
1292
1316
  isCalendarEvent(message.object.type)) {
1317
+ if (message.object.type === 'recurringEvent') {
1318
+ dispatch(fetchEvents({}));
1319
+ return;
1320
+ }
1293
1321
  dispatch(CalendarEventsSlice.actions.removeEvent({ uri: message.object.uri }));
1294
1322
  }
1295
1323
  };
@@ -1297,9 +1325,18 @@ const getCalendarRTHandlers = function (dispatch, jApi) {
1297
1325
  if (message.namespace === 'JAMESPOT' &&
1298
1326
  message.function === 'article-update' &&
1299
1327
  isCalendarEvent(message.object.type)) {
1300
- jApi.article.get({ uri: message.object.uri }, { format: 'raw-view', formatExtension: ['socialEventRecord'] })
1328
+ if (message.object.type === 'recurringEvent') {
1329
+ dispatch(fetchEvents({}));
1330
+ return;
1331
+ }
1332
+ jApi.article.get({ uri: message.object.uri }, { format: 'raw-view', formatExtension: ['socialEventRecord', 'recurringEventRecord'] })
1301
1333
  .then((res) => {
1302
- dispatch(CalendarEventsSlice.actions.updateEvent(res.result));
1334
+ if ('hideFromCalendar' in res.result && res.result.hideFromCalendar) {
1335
+ dispatch(CalendarEventsSlice.actions.removeEvent({ uri: message.object.uri }));
1336
+ }
1337
+ else {
1338
+ dispatch(CalendarEventsSlice.actions.updateEvent(res.result));
1339
+ }
1303
1340
  })
1304
1341
  .catch((e) => {
1305
1342
  dispatch(Toast.actions.error({ label: getErrorMessage(e) }));
@@ -1307,12 +1344,12 @@ const getCalendarRTHandlers = function (dispatch, jApi) {
1307
1344
  }
1308
1345
  };
1309
1346
  const updateResponseHandler = function (message) {
1310
- if ((message.namespace === 'CUSTOM-ACTION' &&
1347
+ if (message.namespace === 'CUSTOM-ACTION' &&
1311
1348
  (message.function === 'update' || message.function === 'remove') &&
1312
1349
  message.object.targetType &&
1313
1350
  message.object.targetId &&
1314
- isCalendarEvent(message.object.targetType))) {
1315
- jApi.article.get({ idArticle: message.object.targetId }, { format: 'raw-view', formatExtension: ['socialEventRecord'] })
1351
+ isCalendarEvent(message.object.targetType)) {
1352
+ jApi.article.get({ idArticle: message.object.targetId }, { format: 'raw-view', formatExtension: ['socialEventRecord', 'recurringEventRecord'] })
1316
1353
  .then((res) => {
1317
1354
  dispatch(CalendarEventsSlice.actions.updateEvent(res.result));
1318
1355
  })