@forcecalendar/interface 1.0.15 → 1.0.16
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.
|
@@ -1051,9 +1051,9 @@ class M {
|
|
|
1051
1051
|
reminders: I = [],
|
|
1052
1052
|
category: L,
|
|
1053
1053
|
// Support singular category (no default)
|
|
1054
|
-
categories:
|
|
1054
|
+
categories: F,
|
|
1055
1055
|
// Support plural categories (no default)
|
|
1056
|
-
attachments:
|
|
1056
|
+
attachments: O = [],
|
|
1057
1057
|
conferenceData: R = null,
|
|
1058
1058
|
metadata: H = {},
|
|
1059
1059
|
...B
|
|
@@ -1082,9 +1082,9 @@ class M {
|
|
|
1082
1082
|
reminders: I,
|
|
1083
1083
|
category: L,
|
|
1084
1084
|
// Pass category to normalize
|
|
1085
|
-
categories:
|
|
1085
|
+
categories: F,
|
|
1086
1086
|
// Pass categories to normalize
|
|
1087
|
-
attachments:
|
|
1087
|
+
attachments: O,
|
|
1088
1088
|
conferenceData: R,
|
|
1089
1089
|
metadata: H,
|
|
1090
1090
|
...B
|
|
@@ -5042,7 +5042,23 @@ class J {
|
|
|
5042
5042
|
loading: !1,
|
|
5043
5043
|
error: null,
|
|
5044
5044
|
config: { ...e }
|
|
5045
|
-
}, this.subscribers = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this), this.unsubscribe = this.unsubscribe.bind(this), this.setState = this.setState.bind(this);
|
|
5045
|
+
}, this.subscribers = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this), this.unsubscribe = this.unsubscribe.bind(this), this.setState = this.setState.bind(this), this._syncEventsFromCore({ silent: !0 });
|
|
5046
|
+
}
|
|
5047
|
+
/**
|
|
5048
|
+
* Sync state.events from Core calendar (single source of truth)
|
|
5049
|
+
* This ensures state.events always matches Core's event store
|
|
5050
|
+
*/
|
|
5051
|
+
_syncEventsFromCore(e = {}) {
|
|
5052
|
+
const t = this.calendar.getEvents() || [];
|
|
5053
|
+
return (this.state.events.length !== t.length || !this._eventsMatch(this.state.events, t)) && this.setState({ events: [...t] }, e), t;
|
|
5054
|
+
}
|
|
5055
|
+
/**
|
|
5056
|
+
* Check if two event arrays have the same events (by id)
|
|
5057
|
+
*/
|
|
5058
|
+
_eventsMatch(e, t) {
|
|
5059
|
+
if (e.length !== t.length) return !1;
|
|
5060
|
+
const s = new Set(e.map((i) => i.id));
|
|
5061
|
+
return t.every((i) => s.has(i.id));
|
|
5046
5062
|
}
|
|
5047
5063
|
// State management
|
|
5048
5064
|
getState() {
|
|
@@ -5108,29 +5124,25 @@ class J {
|
|
|
5108
5124
|
// Event management
|
|
5109
5125
|
addEvent(e) {
|
|
5110
5126
|
const t = this.calendar.addEvent(e);
|
|
5111
|
-
|
|
5112
|
-
return console.error("Failed to add event to calendar"), y.emit("event:error", { action: "add", event: e, error: "Failed to add event" }), null;
|
|
5113
|
-
const s = [...this.state.events, t];
|
|
5114
|
-
return this.setState({ events: s }), y.emit("event:added", { event: t }), t;
|
|
5127
|
+
return t ? (this._syncEventsFromCore(), y.emit("event:added", { event: t }), t) : (console.error("Failed to add event to calendar"), y.emit("event:error", { action: "add", event: e, error: "Failed to add event" }), null);
|
|
5115
5128
|
}
|
|
5116
5129
|
updateEvent(e, t) {
|
|
5130
|
+
this._syncEventsFromCore({ silent: !0 });
|
|
5117
5131
|
const s = this.calendar.updateEvent(e, t);
|
|
5118
|
-
|
|
5119
|
-
return console.error(`Failed to update event: ${e}`), y.emit("event:error", { action: "update", eventId: e, updates: t, error: "Event not found in calendar" }), null;
|
|
5120
|
-
const i = this.state.events.findIndex((n) => n.id === e);
|
|
5121
|
-
if (i === -1)
|
|
5122
|
-
return console.error(`Event ${e} not found in state`), y.emit("event:error", { action: "update", eventId: e, error: "Event not found in state" }), null;
|
|
5123
|
-
const r = [...this.state.events];
|
|
5124
|
-
return r[i] = s, this.setState({ events: r }), y.emit("event:updated", { event: s }), s;
|
|
5132
|
+
return s ? (this._syncEventsFromCore(), y.emit("event:updated", { event: s }), s) : (console.error(`Failed to update event: ${e}`), y.emit("event:error", { action: "update", eventId: e, updates: t, error: "Event not found in calendar" }), null);
|
|
5125
5133
|
}
|
|
5126
5134
|
deleteEvent(e) {
|
|
5127
|
-
|
|
5128
|
-
return console.error(`Failed to delete event: ${e}`), y.emit("event:error", { action: "delete", eventId: e, error: "Event not found" }), !1;
|
|
5129
|
-
const s = this.state.events.filter((i) => i.id !== e);
|
|
5130
|
-
return this.setState({ events: s }), y.emit("event:deleted", { eventId: e }), !0;
|
|
5135
|
+
return this._syncEventsFromCore({ silent: !0 }), this.calendar.removeEvent(e) ? (this._syncEventsFromCore(), y.emit("event:deleted", { eventId: e }), !0) : (console.error(`Failed to delete event: ${e}`), y.emit("event:error", { action: "delete", eventId: e, error: "Event not found" }), !1);
|
|
5131
5136
|
}
|
|
5132
5137
|
getEvents() {
|
|
5133
|
-
return this.calendar.getEvents();
|
|
5138
|
+
return this.calendar.getEvents() || [];
|
|
5139
|
+
}
|
|
5140
|
+
/**
|
|
5141
|
+
* Force sync state.events from Core calendar
|
|
5142
|
+
* Use this if you've modified events directly on the Core calendar
|
|
5143
|
+
*/
|
|
5144
|
+
syncEvents() {
|
|
5145
|
+
return this._syncEventsFromCore();
|
|
5134
5146
|
}
|
|
5135
5147
|
getEventsForDate(e) {
|
|
5136
5148
|
return this.calendar.getEventsForDate(e);
|