@sprucelabs/spruce-calendar-components 25.6.2 → 25.6.4

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.
@@ -49,6 +49,7 @@ export default class CalendarEventManager {
49
49
  makeCalendarVisible(calendarId: string): Promise<void>;
50
50
  makeCalendarHidden(calendarId: string): Promise<void>;
51
51
  updateEvent(id: string, updates: UpdateEventOptions): void;
52
+ private calculateDifferences;
52
53
  loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[]>;
53
54
  setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
54
55
  setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
@@ -178,15 +178,16 @@ class CalendarEventManager {
178
178
  updateEvent(id, updates) {
179
179
  var _a;
180
180
  const { shouldPersist } = updates, rest = __rest(updates, ["shouldPersist"]);
181
- const match = this.allEvents.find((e) => e.id === id);
182
- const updated = Object.assign(Object.assign({}, match), updates);
183
- const isTheSame = (0, isEqual_1.default)(match, updated);
181
+ const { isTheSame, isTheSameWithoutBusy } = this.calculateDifferences(id, updates);
184
182
  if (isTheSame) {
185
183
  return;
186
184
  }
187
185
  this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist }));
188
186
  const idx = this.allEvents.findIndex((e) => e.id === id);
189
187
  this.allEvents[idx] = Object.assign(Object.assign({}, this.allEvents[idx]), rest);
188
+ if (isTheSameWithoutBusy) {
189
+ return;
190
+ }
190
191
  this.refreshShifts();
191
192
  if (this.shouldUpdateContextOnNextSave &&
192
193
  ((_a = this.sm.getContext().event) === null || _a === void 0 ? void 0 : _a.id) === id) {
@@ -197,6 +198,17 @@ class CalendarEventManager {
197
198
  }
198
199
  this.shouldUpdateContextOnNextSave = true;
199
200
  }
201
+ calculateDifferences(id, updates) {
202
+ const match = this.allEvents.find((e) => e.id === id);
203
+ const updated = Object.assign(Object.assign({}, match), updates);
204
+ const isTheSame = (0, isEqual_1.default)(match, updated);
205
+ const updatesWithoutBusy = Object.assign({}, updated);
206
+ delete updatesWithoutBusy.isBusy;
207
+ const matchWithoutBusy = Object.assign({}, match);
208
+ delete matchWithoutBusy.isBusy;
209
+ const isTheSameWithoutBusy = (0, isEqual_1.default)(matchWithoutBusy, updatesWithoutBusy);
210
+ return { isTheSame, isTheSameWithoutBusy };
211
+ }
200
212
  async loadEvents(startDate, endDate, peopleIds) {
201
213
  const events = await this.events.getSchedules({
202
214
  calendarIds: this.calendarIds,
@@ -49,6 +49,7 @@ export default class CalendarEventManager {
49
49
  makeCalendarVisible(calendarId: string): Promise<void>;
50
50
  makeCalendarHidden(calendarId: string): Promise<void>;
51
51
  updateEvent(id: string, updates: UpdateEventOptions): void;
52
+ private calculateDifferences;
52
53
  loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[]>;
53
54
  setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
54
55
  setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
@@ -198,15 +198,16 @@ export default class CalendarEventManager {
198
198
  updateEvent(id, updates) {
199
199
  var _a;
200
200
  const { shouldPersist } = updates, rest = __rest(updates, ["shouldPersist"]);
201
- const match = this.allEvents.find((e) => e.id === id);
202
- const updated = Object.assign(Object.assign({}, match), updates);
203
- const isTheSame = isEqual(match, updated);
201
+ const { isTheSame, isTheSameWithoutBusy } = this.calculateDifferences(id, updates);
204
202
  if (isTheSame) {
205
203
  return;
206
204
  }
207
205
  this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist }));
208
206
  const idx = this.allEvents.findIndex((e) => e.id === id);
209
207
  this.allEvents[idx] = Object.assign(Object.assign({}, this.allEvents[idx]), rest);
208
+ if (isTheSameWithoutBusy) {
209
+ return;
210
+ }
210
211
  this.refreshShifts();
211
212
  if (this.shouldUpdateContextOnNextSave &&
212
213
  ((_a = this.sm.getContext().event) === null || _a === void 0 ? void 0 : _a.id) === id) {
@@ -217,6 +218,17 @@ export default class CalendarEventManager {
217
218
  }
218
219
  this.shouldUpdateContextOnNextSave = true;
219
220
  }
221
+ calculateDifferences(id, updates) {
222
+ const match = this.allEvents.find((e) => e.id === id);
223
+ const updated = Object.assign(Object.assign({}, match), updates);
224
+ const isTheSame = isEqual(match, updated);
225
+ const updatesWithoutBusy = Object.assign({}, updated);
226
+ delete updatesWithoutBusy.isBusy;
227
+ const matchWithoutBusy = Object.assign({}, match);
228
+ delete matchWithoutBusy.isBusy;
229
+ const isTheSameWithoutBusy = isEqual(matchWithoutBusy, updatesWithoutBusy);
230
+ return { isTheSame, isTheSameWithoutBusy };
231
+ }
220
232
  loadEvents(startDate, endDate, peopleIds) {
221
233
  return __awaiter(this, void 0, void 0, function* () {
222
234
  const events = yield this.events.getSchedules({
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.2",
4
+ "version": "25.6.4",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },