@sprucelabs/spruce-calendar-components 25.6.2 → 25.6.3

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,16 +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);
190
- this.refreshShifts();
188
+ if (!isTheSameWithoutBusy) {
189
+ this.refreshShifts();
190
+ }
191
191
  if (this.shouldUpdateContextOnNextSave &&
192
192
  ((_a = this.sm.getContext().event) === null || _a === void 0 ? void 0 : _a.id) === id) {
193
193
  this.shouldIgnoreNextContextUpdate = true;
@@ -197,6 +197,17 @@ class CalendarEventManager {
197
197
  }
198
198
  this.shouldUpdateContextOnNextSave = true;
199
199
  }
200
+ calculateDifferences(id, updates) {
201
+ const match = this.allEvents.find((e) => e.id === id);
202
+ const updated = Object.assign(Object.assign({}, match), updates);
203
+ const isTheSame = (0, isEqual_1.default)(match, updated);
204
+ const updatesWithoutBusy = Object.assign({}, updated);
205
+ delete updatesWithoutBusy.isBusy;
206
+ const matchWithoutBusy = Object.assign({}, match);
207
+ delete matchWithoutBusy.isBusy;
208
+ const isTheSameWithoutBusy = (0, isEqual_1.default)(matchWithoutBusy, updatesWithoutBusy);
209
+ return { isTheSame, isTheSameWithoutBusy };
210
+ }
200
211
  async loadEvents(startDate, endDate, peopleIds) {
201
212
  const events = await this.events.getSchedules({
202
213
  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,16 +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);
210
- this.refreshShifts();
208
+ if (!isTheSameWithoutBusy) {
209
+ this.refreshShifts();
210
+ }
211
211
  if (this.shouldUpdateContextOnNextSave &&
212
212
  ((_a = this.sm.getContext().event) === null || _a === void 0 ? void 0 : _a.id) === id) {
213
213
  this.shouldIgnoreNextContextUpdate = true;
@@ -217,6 +217,17 @@ export default class CalendarEventManager {
217
217
  }
218
218
  this.shouldUpdateContextOnNextSave = true;
219
219
  }
220
+ calculateDifferences(id, updates) {
221
+ const match = this.allEvents.find((e) => e.id === id);
222
+ const updated = Object.assign(Object.assign({}, match), updates);
223
+ const isTheSame = isEqual(match, updated);
224
+ const updatesWithoutBusy = Object.assign({}, updated);
225
+ delete updatesWithoutBusy.isBusy;
226
+ const matchWithoutBusy = Object.assign({}, match);
227
+ delete matchWithoutBusy.isBusy;
228
+ const isTheSameWithoutBusy = isEqual(matchWithoutBusy, updatesWithoutBusy);
229
+ return { isTheSame, isTheSameWithoutBusy };
230
+ }
220
231
  loadEvents(startDate, endDate, peopleIds) {
221
232
  return __awaiter(this, void 0, void 0, function* () {
222
233
  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.3",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },