@sprucelabs/spruce-calendar-components 22.3.16 → 22.3.17

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.
@@ -249,6 +249,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
249
249
  }
250
250
  handleDraftEventAdded(event) {
251
251
  return __awaiter(this, void 0, void 0, function* () {
252
+ console.log('handle draft event added');
252
253
  yield this.events.addDraftEvent(event, !event.eventTypeSlug);
253
254
  if (!event.eventTypeSlug) {
254
255
  this.toolBeltVc.open({ shouldStayOpen: true });
@@ -256,9 +257,9 @@ export default class RootSkillViewController extends AbstractSkillViewController
256
257
  }
257
258
  });
258
259
  }
259
- handleEventSwapped(event) {
260
+ handleEventSwapped(draft, event) {
260
261
  return __awaiter(this, void 0, void 0, function* () {
261
- yield this.events.silentlySwapEvent(this.sm.getContext().event.id, event);
262
+ yield this.events.silentlySwapEvent(draft.id, event);
262
263
  });
263
264
  }
264
265
  handleDropEvent(id, updates) {
@@ -4,7 +4,7 @@ import { UpdateEvent } from '../types/calendar.types';
4
4
  declare type Calendar = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Calendar;
5
5
  declare type Event = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
6
6
  declare type DraftAddedHandler = (event: Event) => void | Promise<void>;
7
- declare type EventSwappedHandler = (event: Event) => void | Promise<void>;
7
+ declare type EventSwappedHandler = (draft: Event, saved: Event) => void | Promise<void>;
8
8
  declare type EventDroppedHandler = (id: string, updates: Partial<Event>) => boolean | Promise<boolean>;
9
9
  declare type DraftRemovedHandler = () => void | Promise<void>;
10
10
  declare type ClickEventHandler = (options: ClickEventOptions) => void | Promise<void>;
@@ -28,14 +28,14 @@ export default class CalendarViewController extends CoreCalendarViewController {
28
28
  super(Object.assign(Object.assign({ view: 'day' }, rest), { onDropEvent: (options) => {
29
29
  return this.handleDropEvent(options);
30
30
  } }));
31
- this.activelyPersisting = 0;
31
+ this.activelyPersisting = {};
32
32
  this.isSwapping = false;
33
33
  assertOptions(options, ['onAddDraftEvent']);
34
- const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped: onDraftEventSaved, } = rest;
34
+ const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped } = rest;
35
35
  this.sorter = new PeopleSorter();
36
36
  this.draftAddedHandler = onAddDraftEvent;
37
37
  this.draftRemovedHandler = onRemoveDraftEvent;
38
- this.eventSwappedHandler = onDraftEventSaved;
38
+ this.eventSwappedHandler = onEventSwapped;
39
39
  this.dropEventHandler = onDropEvent;
40
40
  this.remoteEventStore = remoteEventStore;
41
41
  this.model.onClick = this.handleClick.bind(this);
@@ -189,9 +189,14 @@ export default class CalendarViewController extends CoreCalendarViewController {
189
189
  const id = event.id;
190
190
  const isBusy = (options === null || options === void 0 ? void 0 : options.isBusy) === true;
191
191
  try {
192
- this.activelyPersisting++;
192
+ if (!this.activelyPersisting[id]) {
193
+ this.activelyPersisting[id] = 1;
194
+ }
195
+ else {
196
+ this.activelyPersisting[id]++;
197
+ }
193
198
  const saved = yield ((_a = this.remoteEventStore) === null || _a === void 0 ? void 0 : _a.persist(Object.assign(Object.assign({}, event), { isBusy })));
194
- this.activelyPersisting--;
199
+ this.activelyPersisting[id]--;
195
200
  if (!saved) {
196
201
  return;
197
202
  }
@@ -203,8 +208,8 @@ export default class CalendarViewController extends CoreCalendarViewController {
203
208
  this.lastSwappedId = id;
204
209
  yield this.swapEvent(event, saved);
205
210
  }
206
- if (this.activelyPersisting === 0) {
207
- yield ((_b = this.eventSwappedHandler) === null || _b === void 0 ? void 0 : _b.call(this, saved));
211
+ if (this.activelyPersisting[id] === 0) {
212
+ yield ((_b = this.eventSwappedHandler) === null || _b === void 0 ? void 0 : _b.call(this, event, saved));
208
213
  }
209
214
  }
210
215
  else {
@@ -220,14 +220,15 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
220
220
  }
221
221
  }
222
222
  async handleDraftEventAdded(event) {
223
+ console.log('handle draft event added');
223
224
  await this.events.addDraftEvent(event, !event.eventTypeSlug);
224
225
  if (!event.eventTypeSlug) {
225
226
  this.toolBeltVc.open({ shouldStayOpen: true });
226
227
  await this.sm.transitionTo(this.toolBeltStates.prerequisites);
227
228
  }
228
229
  }
229
- async handleEventSwapped(event) {
230
- await this.events.silentlySwapEvent(this.sm.getContext().event.id, event);
230
+ async handleEventSwapped(draft, event) {
231
+ await this.events.silentlySwapEvent(draft.id, event);
231
232
  }
232
233
  async handleDropEvent(id, updates) {
233
234
  return this.events.handleDropEvent(id, updates);
@@ -4,7 +4,7 @@ import { UpdateEvent } from '../types/calendar.types';
4
4
  declare type Calendar = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Calendar;
5
5
  declare type Event = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
6
6
  declare type DraftAddedHandler = (event: Event) => void | Promise<void>;
7
- declare type EventSwappedHandler = (event: Event) => void | Promise<void>;
7
+ declare type EventSwappedHandler = (draft: Event, saved: Event) => void | Promise<void>;
8
8
  declare type EventDroppedHandler = (id: string, updates: Partial<Event>) => boolean | Promise<boolean>;
9
9
  declare type DraftRemovedHandler = () => void | Promise<void>;
10
10
  declare type ClickEventHandler = (options: ClickEventOptions) => void | Promise<void>;
@@ -24,14 +24,14 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
24
24
  super(Object.assign(Object.assign({ view: 'day' }, rest), { onDropEvent: (options) => {
25
25
  return this.handleDropEvent(options);
26
26
  } }));
27
- this.activelyPersisting = 0;
27
+ this.activelyPersisting = {};
28
28
  this.isSwapping = false;
29
29
  (0, schema_1.assertOptions)(options, ['onAddDraftEvent']);
30
- const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped: onDraftEventSaved, } = rest;
30
+ const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped } = rest;
31
31
  this.sorter = new calendar_utils_1.PeopleSorter();
32
32
  this.draftAddedHandler = onAddDraftEvent;
33
33
  this.draftRemovedHandler = onRemoveDraftEvent;
34
- this.eventSwappedHandler = onDraftEventSaved;
34
+ this.eventSwappedHandler = onEventSwapped;
35
35
  this.dropEventHandler = onDropEvent;
36
36
  this.remoteEventStore = remoteEventStore;
37
37
  this.model.onClick = this.handleClick.bind(this);
@@ -166,9 +166,14 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
166
166
  const id = event.id;
167
167
  const isBusy = (options === null || options === void 0 ? void 0 : options.isBusy) === true;
168
168
  try {
169
- this.activelyPersisting++;
169
+ if (!this.activelyPersisting[id]) {
170
+ this.activelyPersisting[id] = 1;
171
+ }
172
+ else {
173
+ this.activelyPersisting[id]++;
174
+ }
170
175
  const saved = await ((_a = this.remoteEventStore) === null || _a === void 0 ? void 0 : _a.persist(Object.assign(Object.assign({}, event), { isBusy })));
171
- this.activelyPersisting--;
176
+ this.activelyPersisting[id]--;
172
177
  if (!saved) {
173
178
  return;
174
179
  }
@@ -180,8 +185,8 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
180
185
  this.lastSwappedId = id;
181
186
  await this.swapEvent(event, saved);
182
187
  }
183
- if (this.activelyPersisting === 0) {
184
- await ((_b = this.eventSwappedHandler) === null || _b === void 0 ? void 0 : _b.call(this, saved));
188
+ if (this.activelyPersisting[id] === 0) {
189
+ await ((_b = this.eventSwappedHandler) === null || _b === void 0 ? void 0 : _b.call(this, event, saved));
185
190
  }
186
191
  }
187
192
  else {
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": "22.3.16",
4
+ "version": "22.3.17",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },