@sprucelabs/spruce-calendar-components 24.3.6 → 24.3.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.
@@ -73,7 +73,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
73
73
  private loadScope;
74
74
  protected syncPeopleOnCalendar(): void;
75
75
  private syncOffsetWithLocale;
76
- protected loadEvents(): Promise<void>;
76
+ protected loadEvents(options?: LoadEventOptions): Promise<void>;
77
77
  private _loadEvents;
78
78
  protected transitionToRoot(): Promise<void>;
79
79
  private loadLoggedInPerson;
@@ -86,3 +86,6 @@ export interface RootArgs {
86
86
  startDate?: number;
87
87
  visiblePeopleIds?: string[];
88
88
  }
89
+ export type LoadEventOptions = {
90
+ shouldRenderAlertOnFail: boolean;
91
+ };
@@ -365,13 +365,15 @@ class RootSkillViewController extends AbstractSkillViewController {
365
365
  yield this.people.setVisibilityMode('custom');
366
366
  yield this.people.setVisiblePeopleIds(visiblePeopleIds);
367
367
  }
368
- yield this.waitUntilDoneSaving();
369
368
  if (RootSkillViewController.shouldUpdateOnInterval) {
370
369
  this.loadEventInterval = setInterval(() => {
371
- return this.loadEvents();
370
+ return this.loadEvents({
371
+ shouldRenderAlertOnFail: false,
372
+ });
372
373
  }, RootSkillViewController.refreshInterval);
373
374
  }
374
375
  yield this.client.on('connection-status-change', this.handleStateChange);
376
+ yield this.waitUntilDoneSaving();
375
377
  });
376
378
  }
377
379
  handleStateChange(options) {
@@ -383,9 +385,10 @@ class RootSkillViewController extends AbstractSkillViewController {
383
385
  });
384
386
  }
385
387
  destroy() {
388
+ var _a;
386
389
  return __awaiter(this, void 0, void 0, function* () {
387
390
  clearInterval(this.loadEventInterval);
388
- yield this.client.off('connection-status-change', this.handleStateChange);
391
+ yield ((_a = this.client) === null || _a === void 0 ? void 0 : _a.off('connection-status-change', this.handleStateChange));
389
392
  });
390
393
  }
391
394
  setupCalendarEventListeners() {
@@ -458,13 +461,13 @@ class RootSkillViewController extends AbstractSkillViewController {
458
461
  const offset = locale.getTimezoneOffsetMinutes();
459
462
  this.calendarVc.setTimezoneOffsetMs(offset * 60 * 1000);
460
463
  }
461
- loadEvents() {
464
+ loadEvents(options) {
462
465
  return __awaiter(this, void 0, void 0, function* () {
463
- this.loadEventsPromise = this._loadEvents();
466
+ this.loadEventsPromise = this._loadEvents(options);
464
467
  yield this.loadEventsPromise;
465
468
  });
466
469
  }
467
- _loadEvents() {
470
+ _loadEvents(options) {
468
471
  var _a;
469
472
  return __awaiter(this, void 0, void 0, function* () {
470
473
  try {
@@ -477,6 +480,12 @@ class RootSkillViewController extends AbstractSkillViewController {
477
480
  }
478
481
  }
479
482
  catch (err) {
483
+ if ((options === null || options === void 0 ? void 0 : options.shouldRenderAlertOnFail) === false) {
484
+ this.toast({
485
+ message: 'Updating your calendar failed! Trying again now...',
486
+ });
487
+ return;
488
+ }
480
489
  console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
481
490
  void this.alert({
482
491
  message: err.message,
@@ -73,7 +73,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
73
73
  private loadScope;
74
74
  protected syncPeopleOnCalendar(): void;
75
75
  private syncOffsetWithLocale;
76
- protected loadEvents(): Promise<void>;
76
+ protected loadEvents(options?: LoadEventOptions): Promise<void>;
77
77
  private _loadEvents;
78
78
  protected transitionToRoot(): Promise<void>;
79
79
  private loadLoggedInPerson;
@@ -86,3 +86,6 @@ export interface RootArgs {
86
86
  startDate?: number;
87
87
  visiblePeopleIds?: string[];
88
88
  }
89
+ export type LoadEventOptions = {
90
+ shouldRenderAlertOnFail: boolean;
91
+ };
@@ -324,13 +324,15 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
324
324
  await this.people.setVisibilityMode('custom');
325
325
  await this.people.setVisiblePeopleIds(visiblePeopleIds);
326
326
  }
327
- await this.waitUntilDoneSaving();
328
327
  if (RootSkillViewController.shouldUpdateOnInterval) {
329
328
  this.loadEventInterval = setInterval(() => {
330
- return this.loadEvents();
329
+ return this.loadEvents({
330
+ shouldRenderAlertOnFail: false,
331
+ });
331
332
  }, RootSkillViewController.refreshInterval);
332
333
  }
333
334
  await this.client.on('connection-status-change', this.handleStateChange);
335
+ await this.waitUntilDoneSaving();
334
336
  }
335
337
  async handleStateChange(options) {
336
338
  const { status } = options.payload;
@@ -339,8 +341,9 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
339
341
  }
340
342
  }
341
343
  async destroy() {
344
+ var _a;
342
345
  clearInterval(this.loadEventInterval);
343
- await this.client.off('connection-status-change', this.handleStateChange);
346
+ await ((_a = this.client) === null || _a === void 0 ? void 0 : _a.off('connection-status-change', this.handleStateChange));
344
347
  }
345
348
  async setupCalendarEventListeners() {
346
349
  await Promise.all([
@@ -400,11 +403,11 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
400
403
  const offset = locale.getTimezoneOffsetMinutes();
401
404
  this.calendarVc.setTimezoneOffsetMs(offset * 60 * 1000);
402
405
  }
403
- async loadEvents() {
404
- this.loadEventsPromise = this._loadEvents();
406
+ async loadEvents(options) {
407
+ this.loadEventsPromise = this._loadEvents(options);
405
408
  await this.loadEventsPromise;
406
409
  }
407
- async _loadEvents() {
410
+ async _loadEvents(options) {
408
411
  var _a;
409
412
  try {
410
413
  if (this.events.getCalendars().length > 0) {
@@ -416,6 +419,12 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
416
419
  }
417
420
  }
418
421
  catch (err) {
422
+ if ((options === null || options === void 0 ? void 0 : options.shouldRenderAlertOnFail) === false) {
423
+ this.toast({
424
+ message: 'Updating your calendar failed! Trying again now...',
425
+ });
426
+ return;
427
+ }
419
428
  console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
420
429
  void this.alert({
421
430
  message: err.message,
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": "24.3.6",
4
+ "version": "24.3.8",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },