@sprucelabs/spruce-calendar-components 25.4.2 → 25.5.1

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.
@@ -48,6 +48,7 @@ export default class SpyEventManager extends CalendarEventManager {
48
48
  meta?: Record<string, any> | null | undefined;
49
49
  error?: Error | null | undefined;
50
50
  isSelected?: boolean | null | undefined;
51
+ colors?: import("@sprucelabs/spruce-core-schemas").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEventColorOverride | null | undefined;
51
52
  controller?: import("@sprucelabs/heartwood-view-controllers").CalendarEventViewController | null | undefined;
52
53
  }>;
53
54
  }
@@ -39,6 +39,7 @@ export default class CalendarEventManager {
39
39
  getCalendars(): import("@sprucelabs/calendar-utils").SpruceSchemas.Calendar.v2021_05_19.Calendar[];
40
40
  addDraftEvent(event: CalendarEvent, shouldSelectEvent?: boolean): Promise<void>;
41
41
  addEvent(event: CalendarEvent): void;
42
+ addEvents(events: CalendarEvent[]): void;
42
43
  silentlySwapEvent(oldId: string, event: CalendarEvent): Promise<void>;
43
44
  handleDropEvent(id: string, updates: Partial<CalendarEvent>): Promise<boolean>;
44
45
  reset(): Promise<void>;
@@ -52,7 +53,7 @@ export default class CalendarEventManager {
52
53
  shouldUpdateAllEventsGoingForward?: boolean;
53
54
  shouldPersist?: boolean;
54
55
  }): void;
55
- loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<void>;
56
+ loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[]>;
56
57
  setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
57
58
  setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
58
59
  private assertValidCalendarId;
@@ -81,6 +82,7 @@ export default class CalendarEventManager {
81
82
  meta?: Record<string, any> | null | undefined;
82
83
  error?: Error | null | undefined;
83
84
  isSelected?: boolean | null | undefined;
85
+ colors?: import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEventColorOverride | null | undefined;
84
86
  controller?: import("@sprucelabs/heartwood-view-controllers").CalendarEventViewController | null | undefined;
85
87
  }>;
86
88
  private setEventInContext;
@@ -102,6 +102,10 @@ export default class CalendarEventManager {
102
102
  this.allEvents.push(Object.assign({}, event));
103
103
  this.calendarVc.addEvent(event);
104
104
  }
105
+ addEvents(events) {
106
+ this.allEvents.push(...events);
107
+ this.calendarVc.mixinEvents(events);
108
+ }
105
109
  silentlySwapEvent(oldId, event) {
106
110
  var _a;
107
111
  return __awaiter(this, void 0, void 0, function* () {
@@ -215,7 +219,6 @@ export default class CalendarEventManager {
215
219
  peopleIds,
216
220
  });
217
221
  yield this.calendarVc.renderOnce(() => __awaiter(this, void 0, void 0, function* () {
218
- this.replaceEventsInRange(events, startDate, endDate);
219
222
  if (!this.eventTypes) {
220
223
  this.eventTypes = yield this.events.getEventTypes();
221
224
  }
@@ -226,7 +229,9 @@ export default class CalendarEventManager {
226
229
  yield this.setupVcForEventType(type.viewControllerId, type.slug);
227
230
  }
228
231
  })));
232
+ this.replaceEventsInRange(events, startDate, endDate);
229
233
  }));
234
+ return events;
230
235
  });
231
236
  }
232
237
  setCalendarVisibility(calendarId, shouldBeVisible) {
@@ -63,6 +63,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
63
63
  getCalendarSelectVc(): import("../tools/CalendarSelectTool.vc").default | undefined;
64
64
  getCalendarVc(): CalendarViewController;
65
65
  load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
66
+ private optionallyLoadCachedEvents;
66
67
  private handleStateChange;
67
68
  destroy(): Promise<void>;
68
69
  private setupCalendarEventListeners;
@@ -75,6 +76,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
75
76
  private syncOffsetWithLocale;
76
77
  protected loadEvents(options?: LoadEventOptions): Promise<void>;
77
78
  private _loadEvents;
79
+ private cacheEvents;
78
80
  protected transitionToRoot(): Promise<void>;
79
81
  private loadLoggedInPerson;
80
82
  private getVisibleEvents;
@@ -358,13 +358,13 @@ class RootSkillViewController extends AbstractSkillViewController {
358
358
  const { startDate = this.dates.getStartOfDay(), visiblePeopleIds } = args;
359
359
  yield this.calendarVc.renderOnce(() => __awaiter(this, void 0, void 0, function* () {
360
360
  this.syncOffsetWithLocale(locale);
361
- yield this.events.setCurrentDate(startDate);
362
- yield this.transitionToRoot();
361
+ this.optionallyLoadCachedEvents();
363
362
  if (visiblePeopleIds) {
364
363
  yield this.people.setVisibilityMode('custom');
365
364
  yield this.people.setVisiblePeopleIds(visiblePeopleIds);
366
365
  }
367
366
  }));
367
+ yield this.transitionToRoot();
368
368
  if (RootSkillViewController.shouldUpdateOnInterval) {
369
369
  this.loadEventInterval = setInterval(() => {
370
370
  return this.loadEvents({
@@ -373,9 +373,16 @@ class RootSkillViewController extends AbstractSkillViewController {
373
373
  }, RootSkillViewController.refreshInterval);
374
374
  }
375
375
  yield this.client.on('connection-status-change', this.handleStateChange);
376
+ yield this.events.setCurrentDate(startDate);
376
377
  yield this.waitUntilDoneSaving();
377
378
  });
378
379
  }
380
+ optionallyLoadCachedEvents() {
381
+ const events = this.getDevice().getCachedValue('calendarEvents');
382
+ if (events) {
383
+ this.events.addEvents(events);
384
+ }
385
+ }
379
386
  handleStateChange(options) {
380
387
  return __awaiter(this, void 0, void 0, function* () {
381
388
  const { status } = options.payload;
@@ -475,8 +482,9 @@ class RootSkillViewController extends AbstractSkillViewController {
475
482
  const date = this.getStartDate();
476
483
  const startDate = this.dates.getStartOfDay(date);
477
484
  const endDate = this.dates.getEndOfDay(date);
478
- yield this.events.loadEvents(startDate, endDate, this.people.getTeam().map((t) => t.id));
485
+ const events = yield this.events.loadEvents(startDate, endDate, this.people.getTeam().map((t) => t.id));
479
486
  yield this.people.emitDidUpdate();
487
+ this.cacheEvents(events);
480
488
  }
481
489
  }
482
490
  catch (err) {
@@ -493,6 +501,9 @@ class RootSkillViewController extends AbstractSkillViewController {
493
501
  }
494
502
  });
495
503
  }
504
+ cacheEvents(events) {
505
+ this.getDevice().setCachedValue('calendarEvents', events);
506
+ }
496
507
  transitionToRoot() {
497
508
  return __awaiter(this, void 0, void 0, function* () {
498
509
  yield this.sm.transitionTo(this.toolBeltStates.root);
@@ -52,17 +52,18 @@ export default class RemoteEventStoreImpl {
52
52
  this.pendingEvents[event.id] = event;
53
53
  return event;
54
54
  }
55
- if (!this.queueByEventId[this.getId(event.id)]) {
56
- this.queueByEventId[this.getId(event.id)] = [];
55
+ const id = this.getId(event.id);
56
+ if (!this.queueByEventId[id]) {
57
+ this.queueByEventId[id] = [];
57
58
  }
58
59
  const promise = new Promise((resolve, reject) => {
59
- this.queueByEventId[this.getId(event.id)].push({
60
+ this.queueByEventId[id].push({
60
61
  event,
61
62
  resolve,
62
63
  reject,
63
64
  promiseIdx: this.promises.length,
64
65
  });
65
- void this.startQueueForEvent(this.getId(event.id));
66
+ void this.startQueueForEvent(id);
66
67
  });
67
68
  this.promises.push(promise);
68
69
  return promise;
@@ -63,6 +63,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
63
63
  getCalendarSelectVc(): import("../tools/CalendarSelectTool.vc").default | undefined;
64
64
  getCalendarVc(): CalendarViewController;
65
65
  load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
66
+ private optionallyLoadCachedEvents;
66
67
  private handleStateChange;
67
68
  destroy(): Promise<void>;
68
69
  private setupCalendarEventListeners;
@@ -75,6 +76,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
75
76
  private syncOffsetWithLocale;
76
77
  protected loadEvents(options?: LoadEventOptions): Promise<void>;
77
78
  private _loadEvents;
79
+ private cacheEvents;
78
80
  protected transitionToRoot(): Promise<void>;
79
81
  private loadLoggedInPerson;
80
82
  private getVisibleEvents;
@@ -317,13 +317,13 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
317
317
  const { startDate = this.dates.getStartOfDay(), visiblePeopleIds } = args;
318
318
  await this.calendarVc.renderOnce(async () => {
319
319
  this.syncOffsetWithLocale(locale);
320
- await this.events.setCurrentDate(startDate);
321
- await this.transitionToRoot();
320
+ this.optionallyLoadCachedEvents();
322
321
  if (visiblePeopleIds) {
323
322
  await this.people.setVisibilityMode('custom');
324
323
  await this.people.setVisiblePeopleIds(visiblePeopleIds);
325
324
  }
326
325
  });
326
+ await this.transitionToRoot();
327
327
  if (RootSkillViewController.shouldUpdateOnInterval) {
328
328
  this.loadEventInterval = setInterval(() => {
329
329
  return this.loadEvents({
@@ -332,8 +332,15 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
332
332
  }, RootSkillViewController.refreshInterval);
333
333
  }
334
334
  await this.client.on('connection-status-change', this.handleStateChange);
335
+ await this.events.setCurrentDate(startDate);
335
336
  await this.waitUntilDoneSaving();
336
337
  }
338
+ optionallyLoadCachedEvents() {
339
+ const events = this.getDevice().getCachedValue('calendarEvents');
340
+ if (events) {
341
+ this.events.addEvents(events);
342
+ }
343
+ }
337
344
  async handleStateChange(options) {
338
345
  const { status } = options.payload;
339
346
  if (status === 'connected') {
@@ -414,8 +421,9 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
414
421
  const date = this.getStartDate();
415
422
  const startDate = this.dates.getStartOfDay(date);
416
423
  const endDate = this.dates.getEndOfDay(date);
417
- await this.events.loadEvents(startDate, endDate, this.people.getTeam().map((t) => t.id));
424
+ const events = await this.events.loadEvents(startDate, endDate, this.people.getTeam().map((t) => t.id));
418
425
  await this.people.emitDidUpdate();
426
+ this.cacheEvents(events);
419
427
  }
420
428
  }
421
429
  catch (err) {
@@ -431,6 +439,9 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
431
439
  });
432
440
  }
433
441
  }
442
+ cacheEvents(events) {
443
+ this.getDevice().setCachedValue('calendarEvents', events);
444
+ }
434
445
  async transitionToRoot() {
435
446
  await this.sm.transitionTo(this.toolBeltStates.root);
436
447
  }
@@ -45,17 +45,18 @@ class RemoteEventStoreImpl {
45
45
  this.pendingEvents[event.id] = event;
46
46
  return event;
47
47
  }
48
- if (!this.queueByEventId[this.getId(event.id)]) {
49
- this.queueByEventId[this.getId(event.id)] = [];
48
+ const id = this.getId(event.id);
49
+ if (!this.queueByEventId[id]) {
50
+ this.queueByEventId[id] = [];
50
51
  }
51
52
  const promise = new Promise((resolve, reject) => {
52
- this.queueByEventId[this.getId(event.id)].push({
53
+ this.queueByEventId[id].push({
53
54
  event,
54
55
  resolve,
55
56
  reject,
56
57
  promiseIdx: this.promises.length,
57
58
  });
58
- void this.startQueueForEvent(this.getId(event.id));
59
+ void this.startQueueForEvent(id);
59
60
  });
60
61
  this.promises.push(promise);
61
62
  return promise;
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.4.2",
4
+ "version": "25.5.1",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },