@sprucelabs/spruce-calendar-components 24.2.31 → 24.3.0
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.
- package/build/.spruce/schemas/schemas.types.d.ts +671 -671
- package/build/esm/.spruce/schemas/schemas.types.d.ts +671 -671
- package/build/esm/skillViewControllers/Root.svc.d.ts +6 -1
- package/build/esm/skillViewControllers/Root.svc.js +22 -0
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +7 -0
- package/build/esm/tools/EventRepeatingTool.vc.js +2 -0
- package/build/esm/viewControllers/RepeatingControlsList.vc.js +1 -0
- package/build/skillViewControllers/Root.svc.d.ts +6 -1
- package/build/skillViewControllers/Root.svc.js +19 -0
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +7 -0
- package/build/tools/EventRepeatingTool.vc.js +2 -0
- package/build/viewControllers/RepeatingControlsList.vc.js +1 -0
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ import { CalendarEvent, CalendarToolBeltStateMachine } from '../types/calendar.t
|
|
|
8
8
|
export default class RootSkillViewController extends AbstractSkillViewController<RootArgs> {
|
|
9
9
|
static id: string;
|
|
10
10
|
static shouldConfirmDrops: boolean;
|
|
11
|
+
static shouldUpdateOnInterval: boolean;
|
|
12
|
+
static refreshInterval: number;
|
|
11
13
|
private calendarVc;
|
|
12
14
|
private toolBeltVc;
|
|
13
15
|
private person?;
|
|
@@ -26,6 +28,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
26
28
|
protected people: CalendarPeopleManager;
|
|
27
29
|
protected remoteVc: RemoteViewControllerFactory;
|
|
28
30
|
protected draftEvent?: CalendarEvent;
|
|
31
|
+
private loadEventInterval?;
|
|
29
32
|
constructor(options: ViewControllerOptions);
|
|
30
33
|
getScope: () => ScopeFlag[];
|
|
31
34
|
private createToolBeltStates;
|
|
@@ -60,6 +63,8 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
60
63
|
getCalendarSelectVc(): import("../tools/CalendarSelectTool.vc").default | undefined;
|
|
61
64
|
getCalendarVc(): CalendarViewController;
|
|
62
65
|
load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
|
|
66
|
+
private handleStateChange;
|
|
67
|
+
destroy(): Promise<void>;
|
|
63
68
|
private setupCalendarEventListeners;
|
|
64
69
|
private handleDidCancelEvent;
|
|
65
70
|
private handleDidCreateOrUpdateRemoteEvent;
|
|
@@ -68,7 +73,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
68
73
|
private loadScope;
|
|
69
74
|
protected syncPeopleOnCalendar(): void;
|
|
70
75
|
private syncOffsetWithLocale;
|
|
71
|
-
|
|
76
|
+
protected loadEvents(): Promise<void>;
|
|
72
77
|
private _loadEvents;
|
|
73
78
|
protected transitionToRoot(): Promise<void>;
|
|
74
79
|
private loadLoggedInPerson;
|
|
@@ -48,6 +48,7 @@ class RootSkillViewController extends AbstractSkillViewController {
|
|
|
48
48
|
askForUpdateStrategy: this.askForUpdateStrategy.bind(this),
|
|
49
49
|
});
|
|
50
50
|
this.createToolBeltStates();
|
|
51
|
+
this.handleStateChange = this.handleStateChange.bind(this);
|
|
51
52
|
}
|
|
52
53
|
createToolBeltStates() {
|
|
53
54
|
this.toolBeltStates = {
|
|
@@ -365,6 +366,25 @@ class RootSkillViewController extends AbstractSkillViewController {
|
|
|
365
366
|
yield this.people.setVisiblePeopleIds(visiblePeopleIds);
|
|
366
367
|
}
|
|
367
368
|
yield this.waitUntilDoneSaving();
|
|
369
|
+
if (RootSkillViewController.shouldUpdateOnInterval) {
|
|
370
|
+
this.loadEventInterval = setInterval(() => {
|
|
371
|
+
return this.loadEvents();
|
|
372
|
+
}, RootSkillViewController.refreshInterval);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
handleStateChange(options) {
|
|
377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
const { status } = options.payload;
|
|
379
|
+
if (status === 'connected') {
|
|
380
|
+
yield this.loadEvents();
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
destroy() {
|
|
385
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
386
|
+
clearInterval(this.loadEventInterval);
|
|
387
|
+
// await this.client.off('connection-status-change', this.handleStateChange)
|
|
368
388
|
});
|
|
369
389
|
}
|
|
370
390
|
setupCalendarEventListeners() {
|
|
@@ -509,4 +529,6 @@ class RootSkillViewController extends AbstractSkillViewController {
|
|
|
509
529
|
}
|
|
510
530
|
RootSkillViewController.id = 'root';
|
|
511
531
|
RootSkillViewController.shouldConfirmDrops = true;
|
|
532
|
+
RootSkillViewController.shouldUpdateOnInterval = true;
|
|
533
|
+
RootSkillViewController.refreshInterval = 1000 * 60;
|
|
512
534
|
export default RootSkillViewController;
|
|
@@ -21,6 +21,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
21
21
|
this.sm = sm;
|
|
22
22
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
23
23
|
this.isLoaded = true;
|
|
24
|
+
console.log('load in abstract in calendar skill');
|
|
24
25
|
this.controlsVc = sm.Controller('calendar.event-controls-card', Object.assign(Object.assign({ onCancel: this.clearPendingContextChanges.bind(this), onSave: this.handleClickSave.bind(this) }, this.buildVcConstructorOptions('controls')), { onCancelEvent: this.sm.getContext().cancelEvent }));
|
|
25
26
|
this.events = sm.getContext().events;
|
|
26
27
|
this.events.setUpdateContextHandler((updates) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -66,8 +67,10 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
66
67
|
}
|
|
67
68
|
handleDidUpdateContext(skipToolWithId) {
|
|
68
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
console.log('didUpdate skipping', skipToolWithId);
|
|
69
71
|
yield Promise.all(this.vcs.map(({ vc, toolId }) => __awaiter(this, void 0, void 0, function* () {
|
|
70
72
|
if (toolId !== skipToolWithId) {
|
|
73
|
+
console.log('sending to', toolId);
|
|
71
74
|
yield vc.handleUpdateContext(this.getContext());
|
|
72
75
|
}
|
|
73
76
|
})));
|
|
@@ -142,8 +145,10 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
142
145
|
}
|
|
143
146
|
handleUpdateContextFromTool(updates, fromToolId, options) {
|
|
144
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
console.log('handleUpdateContextFromTool', updates);
|
|
145
149
|
const pendingUpdates = Object.assign(Object.assign({}, this.pendingContextUpdates), updates);
|
|
146
150
|
if (compare(this.pendingContextUpdates, pendingUpdates)) {
|
|
151
|
+
console.log('no changes!?');
|
|
147
152
|
return false;
|
|
148
153
|
}
|
|
149
154
|
this.pendingContextUpdates = pendingUpdates;
|
|
@@ -151,9 +156,11 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
151
156
|
const shouldPersistChanges = (vc === null || vc === void 0 ? void 0 : vc.shouldPersistContextChangesImmediately) ||
|
|
152
157
|
(options === null || options === void 0 ? void 0 : options.shouldPersistContextChangesImmediately);
|
|
153
158
|
if (shouldPersistChanges) {
|
|
159
|
+
console.log('updating context right away');
|
|
154
160
|
return this.sm.updateContext(Object.assign({}, updates));
|
|
155
161
|
}
|
|
156
162
|
else {
|
|
163
|
+
console.log('saving as pending');
|
|
157
164
|
yield this.handleDidUpdateContext(fromToolId);
|
|
158
165
|
}
|
|
159
166
|
return false;
|
|
@@ -43,6 +43,7 @@ class EventRepeatingToolViewController extends AbstractViewController {
|
|
|
43
43
|
}
|
|
44
44
|
handleDidChangeRepeating(value) {
|
|
45
45
|
var _a;
|
|
46
|
+
console.log('handleDidChangeRepeating from repeating tool', value);
|
|
46
47
|
const cleaned = this.removeExtraRepeatingFields(value);
|
|
47
48
|
const updates = Object.assign({ repeats: undefined, interval: undefined, repeatsUntil: undefined, occurrences: undefined, daysOfWeek: undefined, daysOfMonth: undefined }, cleaned);
|
|
48
49
|
const keyedUpdates = {};
|
|
@@ -50,6 +51,7 @@ class EventRepeatingToolViewController extends AbstractViewController {
|
|
|
50
51
|
//@ts-ignore
|
|
51
52
|
keyedUpdates[`event.${k}`] = updates[k];
|
|
52
53
|
});
|
|
54
|
+
console.log('calling updateContextHandler in repeating tool');
|
|
53
55
|
const pass = (_a = this.updateContextHandler) === null || _a === void 0 ? void 0 : _a.call(this, Object.assign({}, keyedUpdates));
|
|
54
56
|
return pass;
|
|
55
57
|
}
|
|
@@ -13,6 +13,7 @@ class RepeatingControlsListViewController extends AbstractViewController {
|
|
|
13
13
|
var _a;
|
|
14
14
|
super(options);
|
|
15
15
|
this.repeating = {};
|
|
16
|
+
console.log('repating controls constructor');
|
|
16
17
|
this.repeating = (_a = options.repeating) !== null && _a !== void 0 ? _a : {};
|
|
17
18
|
this.didChangeRepeating = options.didChangeRepeating;
|
|
18
19
|
this.calendarVc = this.CalendarVc();
|
|
@@ -8,6 +8,8 @@ import { CalendarEvent, CalendarToolBeltStateMachine } from '../types/calendar.t
|
|
|
8
8
|
export default class RootSkillViewController extends AbstractSkillViewController<RootArgs> {
|
|
9
9
|
static id: string;
|
|
10
10
|
static shouldConfirmDrops: boolean;
|
|
11
|
+
static shouldUpdateOnInterval: boolean;
|
|
12
|
+
static refreshInterval: number;
|
|
11
13
|
private calendarVc;
|
|
12
14
|
private toolBeltVc;
|
|
13
15
|
private person?;
|
|
@@ -26,6 +28,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
26
28
|
protected people: CalendarPeopleManager;
|
|
27
29
|
protected remoteVc: RemoteViewControllerFactory;
|
|
28
30
|
protected draftEvent?: CalendarEvent;
|
|
31
|
+
private loadEventInterval?;
|
|
29
32
|
constructor(options: ViewControllerOptions);
|
|
30
33
|
getScope: () => ScopeFlag[];
|
|
31
34
|
private createToolBeltStates;
|
|
@@ -60,6 +63,8 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
60
63
|
getCalendarSelectVc(): import("../tools/CalendarSelectTool.vc").default | undefined;
|
|
61
64
|
getCalendarVc(): CalendarViewController;
|
|
62
65
|
load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
|
|
66
|
+
private handleStateChange;
|
|
67
|
+
destroy(): Promise<void>;
|
|
63
68
|
private setupCalendarEventListeners;
|
|
64
69
|
private handleDidCancelEvent;
|
|
65
70
|
private handleDidCreateOrUpdateRemoteEvent;
|
|
@@ -68,7 +73,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
68
73
|
private loadScope;
|
|
69
74
|
protected syncPeopleOnCalendar(): void;
|
|
70
75
|
private syncOffsetWithLocale;
|
|
71
|
-
|
|
76
|
+
protected loadEvents(): Promise<void>;
|
|
72
77
|
private _loadEvents;
|
|
73
78
|
protected transitionToRoot(): Promise<void>;
|
|
74
79
|
private loadLoggedInPerson;
|
|
@@ -44,6 +44,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
44
44
|
askForUpdateStrategy: this.askForUpdateStrategy.bind(this),
|
|
45
45
|
});
|
|
46
46
|
this.createToolBeltStates();
|
|
47
|
+
this.handleStateChange = this.handleStateChange.bind(this);
|
|
47
48
|
}
|
|
48
49
|
createToolBeltStates() {
|
|
49
50
|
this.toolBeltStates = {
|
|
@@ -324,6 +325,22 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
324
325
|
await this.people.setVisiblePeopleIds(visiblePeopleIds);
|
|
325
326
|
}
|
|
326
327
|
await this.waitUntilDoneSaving();
|
|
328
|
+
if (RootSkillViewController.shouldUpdateOnInterval) {
|
|
329
|
+
this.loadEventInterval = setInterval(() => {
|
|
330
|
+
return this.loadEvents();
|
|
331
|
+
}, RootSkillViewController.refreshInterval);
|
|
332
|
+
}
|
|
333
|
+
// await this.client.on('connection-status-change', this.handleStateChange)
|
|
334
|
+
}
|
|
335
|
+
async handleStateChange(options) {
|
|
336
|
+
const { status } = options.payload;
|
|
337
|
+
if (status === 'connected') {
|
|
338
|
+
await this.loadEvents();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async destroy() {
|
|
342
|
+
clearInterval(this.loadEventInterval);
|
|
343
|
+
// await this.client.off('connection-status-change', this.handleStateChange)
|
|
327
344
|
}
|
|
328
345
|
async setupCalendarEventListeners() {
|
|
329
346
|
await Promise.all([
|
|
@@ -447,4 +464,6 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
447
464
|
}
|
|
448
465
|
RootSkillViewController.id = 'root';
|
|
449
466
|
RootSkillViewController.shouldConfirmDrops = true;
|
|
467
|
+
RootSkillViewController.shouldUpdateOnInterval = true;
|
|
468
|
+
RootSkillViewController.refreshInterval = 1000 * 60;
|
|
450
469
|
exports.default = RootSkillViewController;
|
|
@@ -16,6 +16,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
16
16
|
this.sm = sm;
|
|
17
17
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
18
18
|
this.isLoaded = true;
|
|
19
|
+
console.log('load in abstract in calendar skill');
|
|
19
20
|
this.controlsVc = sm.Controller('calendar.event-controls-card', Object.assign(Object.assign({ onCancel: this.clearPendingContextChanges.bind(this), onSave: this.handleClickSave.bind(this) }, this.buildVcConstructorOptions('controls')), { onCancelEvent: this.sm.getContext().cancelEvent }));
|
|
20
21
|
this.events = sm.getContext().events;
|
|
21
22
|
this.events.setUpdateContextHandler(async (updates) => {
|
|
@@ -53,8 +54,10 @@ class AbstractCalendarEventToolBeltState {
|
|
|
53
54
|
await events.deselectEvent();
|
|
54
55
|
}
|
|
55
56
|
async handleDidUpdateContext(skipToolWithId) {
|
|
57
|
+
console.log('didUpdate skipping', skipToolWithId);
|
|
56
58
|
await Promise.all(this.vcs.map(async ({ vc, toolId }) => {
|
|
57
59
|
if (toolId !== skipToolWithId) {
|
|
60
|
+
console.log('sending to', toolId);
|
|
58
61
|
await vc.handleUpdateContext(this.getContext());
|
|
59
62
|
}
|
|
60
63
|
}));
|
|
@@ -119,8 +122,10 @@ class AbstractCalendarEventToolBeltState {
|
|
|
119
122
|
return null;
|
|
120
123
|
}
|
|
121
124
|
async handleUpdateContextFromTool(updates, fromToolId, options) {
|
|
125
|
+
console.log('handleUpdateContextFromTool', updates);
|
|
122
126
|
const pendingUpdates = Object.assign(Object.assign({}, this.pendingContextUpdates), updates);
|
|
123
127
|
if ((0, just_compare_1.default)(this.pendingContextUpdates, pendingUpdates)) {
|
|
128
|
+
console.log('no changes!?');
|
|
124
129
|
return false;
|
|
125
130
|
}
|
|
126
131
|
this.pendingContextUpdates = pendingUpdates;
|
|
@@ -128,9 +133,11 @@ class AbstractCalendarEventToolBeltState {
|
|
|
128
133
|
const shouldPersistChanges = (vc === null || vc === void 0 ? void 0 : vc.shouldPersistContextChangesImmediately) ||
|
|
129
134
|
(options === null || options === void 0 ? void 0 : options.shouldPersistContextChangesImmediately);
|
|
130
135
|
if (shouldPersistChanges) {
|
|
136
|
+
console.log('updating context right away');
|
|
131
137
|
return this.sm.updateContext(Object.assign({}, updates));
|
|
132
138
|
}
|
|
133
139
|
else {
|
|
140
|
+
console.log('saving as pending');
|
|
134
141
|
await this.handleDidUpdateContext(fromToolId);
|
|
135
142
|
}
|
|
136
143
|
return false;
|
|
@@ -36,6 +36,7 @@ class EventRepeatingToolViewController extends heartwood_view_controllers_1.Abst
|
|
|
36
36
|
}
|
|
37
37
|
handleDidChangeRepeating(value) {
|
|
38
38
|
var _a;
|
|
39
|
+
console.log('handleDidChangeRepeating from repeating tool', value);
|
|
39
40
|
const cleaned = this.removeExtraRepeatingFields(value);
|
|
40
41
|
const updates = Object.assign({ repeats: undefined, interval: undefined, repeatsUntil: undefined, occurrences: undefined, daysOfWeek: undefined, daysOfMonth: undefined }, cleaned);
|
|
41
42
|
const keyedUpdates = {};
|
|
@@ -43,6 +44,7 @@ class EventRepeatingToolViewController extends heartwood_view_controllers_1.Abst
|
|
|
43
44
|
//@ts-ignore
|
|
44
45
|
keyedUpdates[`event.${k}`] = updates[k];
|
|
45
46
|
});
|
|
47
|
+
console.log('calling updateContextHandler in repeating tool');
|
|
46
48
|
const pass = (_a = this.updateContextHandler) === null || _a === void 0 ? void 0 : _a.call(this, Object.assign({}, keyedUpdates));
|
|
47
49
|
return pass;
|
|
48
50
|
}
|
|
@@ -6,6 +6,7 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
|
|
|
6
6
|
var _a;
|
|
7
7
|
super(options);
|
|
8
8
|
this.repeating = {};
|
|
9
|
+
console.log('repating controls constructor');
|
|
9
10
|
this.repeating = (_a = options.repeating) !== null && _a !== void 0 ? _a : {};
|
|
10
11
|
this.didChangeRepeating = options.didChangeRepeating;
|
|
11
12
|
this.calendarVc = this.CalendarVc();
|