@sprucelabs/spruce-calendar-components 25.6.7 → 25.6.8

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.
@@ -29,9 +29,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
29
29
  addDraftEvent(e: Omit<Event, 'id'>): Promise<SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent>;
30
30
  getIsSwappingEvent(): boolean;
31
31
  private swapEvent;
32
- updateEvent(id: string, updates: Partial<UpdateEvent> & {
33
- shouldPersist?: boolean;
34
- }): any;
32
+ updateEvent(id: string, updates: UpdateEventOptions): any;
35
33
  private persist;
36
34
  waitForPendingSaves(): Promise<void>;
37
35
  private _persist;
@@ -57,4 +55,7 @@ export interface CalendarViewControllerOptions {
57
55
  onChangeStartDate?: StartDateTimeChangeHandler;
58
56
  onDeselectEvent?: DeselectEventHandler;
59
57
  }
58
+ export type UpdateEventOptions = Partial<UpdateEvent> & {
59
+ shouldPersist?: boolean | null;
60
+ };
60
61
  export {};
@@ -128,8 +128,8 @@ export interface CancelOptions {
128
128
  shouldPersist?: boolean;
129
129
  }
130
130
  export type UpdateEventOptions = Partial<CalendarEvent> & {
131
- dateToUpdate?: number;
132
- shouldUpdateAllEventsGoingForward?: boolean;
133
- shouldPersist?: boolean;
131
+ dateToUpdate?: number | null;
132
+ shouldUpdateAllEventsGoingForward?: boolean | null;
133
+ shouldPersist?: boolean | null;
134
134
  };
135
135
  export {};
@@ -17,9 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
18
18
  const schema_1 = require("@sprucelabs/schema");
19
19
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
20
- const isEqual_1 = __importDefault(require("../stores/isEqual"));
21
20
  const calendarShiftGenerator_1 = __importDefault(require("../utilities/calendarShiftGenerator"));
22
21
  const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
22
+ const calculateEventDifferences_1 = __importDefault(require("./calculateEventDifferences"));
23
23
  class CalendarEventManager {
24
24
  get calendarIds() {
25
25
  return this.calendars.map((c) => c.id);
@@ -223,13 +223,13 @@ class CalendarEventManager {
223
223
  }
224
224
  async _updateEvent(id, updates) {
225
225
  var _a, _b;
226
- const { shouldPersist } = updates, rest = __rest(updates, ["shouldPersist"]);
226
+ const { shouldPersist = true } = updates, rest = __rest(updates, ["shouldPersist"]);
227
227
  const { isTheSame, isTheSameWithoutBusy } = this.calculateDifferences(id, updates);
228
228
  if (isTheSame) {
229
229
  return;
230
230
  }
231
231
  try {
232
- this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist }));
232
+ this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist: shouldPersist && !isTheSameWithoutBusy }));
233
233
  }
234
234
  catch (err) {
235
235
  console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
@@ -249,13 +249,7 @@ class CalendarEventManager {
249
249
  }
250
250
  calculateDifferences(id, updates) {
251
251
  const match = this.allEvents.find((e) => e.id === id);
252
- const updated = Object.assign(Object.assign({}, match), updates);
253
- const isTheSame = (0, isEqual_1.default)(match, updated);
254
- const updatesWithoutBusy = Object.assign({}, updated);
255
- delete updatesWithoutBusy.isBusy;
256
- const matchWithoutBusy = Object.assign({}, match);
257
- delete matchWithoutBusy.isBusy;
258
- const isTheSameWithoutBusy = (0, isEqual_1.default)(matchWithoutBusy, updatesWithoutBusy);
252
+ const { isTheSame, isTheSameWithoutBusy } = (0, calculateEventDifferences_1.default)(match, updates);
259
253
  return { isTheSame, isTheSameWithoutBusy };
260
254
  }
261
255
  async loadEvents(startDate, endDate, peopleIds) {
@@ -29,9 +29,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
29
29
  addDraftEvent(e: Omit<Event, 'id'>): Promise<SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent>;
30
30
  getIsSwappingEvent(): boolean;
31
31
  private swapEvent;
32
- updateEvent(id: string, updates: Partial<UpdateEvent> & {
33
- shouldPersist?: boolean;
34
- }): any;
32
+ updateEvent(id: string, updates: UpdateEventOptions): any;
35
33
  private persist;
36
34
  waitForPendingSaves(): Promise<void>;
37
35
  private _persist;
@@ -57,4 +55,7 @@ export interface CalendarViewControllerOptions {
57
55
  onChangeStartDate?: StartDateTimeChangeHandler;
58
56
  onDeselectEvent?: DeselectEventHandler;
59
57
  }
58
+ export type UpdateEventOptions = Partial<UpdateEvent> & {
59
+ shouldPersist?: boolean | null;
60
+ };
60
61
  export {};
@@ -128,8 +128,8 @@ export interface CancelOptions {
128
128
  shouldPersist?: boolean;
129
129
  }
130
130
  export type UpdateEventOptions = Partial<CalendarEvent> & {
131
- dateToUpdate?: number;
132
- shouldUpdateAllEventsGoingForward?: boolean;
133
- shouldPersist?: boolean;
131
+ dateToUpdate?: number | null;
132
+ shouldUpdateAllEventsGoingForward?: boolean | null;
133
+ shouldPersist?: boolean | null;
134
134
  };
135
135
  export {};
@@ -21,9 +21,9 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  import { calendarEventSchema, } from '@sprucelabs/heartwood-view-controllers';
22
22
  import { assertOptions, normalizeSchemaValues } from '@sprucelabs/schema';
23
23
  import SpruceError from '../errors/SpruceError.js';
24
- import isEqual from '../stores/isEqual.js';
25
24
  import calendarShiftGenerator from '../utilities/calendarShiftGenerator.js';
26
25
  import draftEventGenerator from '../utilities/draftGenerator.js';
26
+ import calculateEventDifferences from './calculateEventDifferences.js';
27
27
  export default class CalendarEventManager {
28
28
  get calendarIds() {
29
29
  return this.calendars.map((c) => c.id);
@@ -248,13 +248,13 @@ export default class CalendarEventManager {
248
248
  _updateEvent(id, updates) {
249
249
  var _a, _b;
250
250
  return __awaiter(this, void 0, void 0, function* () {
251
- const { shouldPersist } = updates, rest = __rest(updates, ["shouldPersist"]);
251
+ const { shouldPersist = true } = updates, rest = __rest(updates, ["shouldPersist"]);
252
252
  const { isTheSame, isTheSameWithoutBusy } = this.calculateDifferences(id, updates);
253
253
  if (isTheSame) {
254
254
  return;
255
255
  }
256
256
  try {
257
- this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist }));
257
+ this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist: shouldPersist && !isTheSameWithoutBusy }));
258
258
  }
259
259
  catch (err) {
260
260
  console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
@@ -275,13 +275,7 @@ export default class CalendarEventManager {
275
275
  }
276
276
  calculateDifferences(id, updates) {
277
277
  const match = this.allEvents.find((e) => e.id === id);
278
- const updated = Object.assign(Object.assign({}, match), updates);
279
- const isTheSame = isEqual(match, updated);
280
- const updatesWithoutBusy = Object.assign({}, updated);
281
- delete updatesWithoutBusy.isBusy;
282
- const matchWithoutBusy = Object.assign({}, match);
283
- delete matchWithoutBusy.isBusy;
284
- const isTheSameWithoutBusy = isEqual(matchWithoutBusy, updatesWithoutBusy);
278
+ const { isTheSame, isTheSameWithoutBusy } = calculateEventDifferences(match, updates);
285
279
  return { isTheSame, isTheSameWithoutBusy };
286
280
  }
287
281
  loadEvents(startDate, endDate, peopleIds) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-calendar-components",
3
3
  "description": "Calendar components for working with calendars and Sprucebot.",
4
- "version": "25.6.7",
4
+ "version": "25.6.8",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },