Ask only the recurrence rules, the live server settles it
A probe against the live 0.16.19 says a one-off event comes back from an expanded query as id "eaaaaai" with baseEventId "i" — an instance id of its own, and a base that is a different event. The clause that treated a differing base as an occurrence of a series would therefore have gone on calling every event recurring, which was the bug. So recurrence rules alone decide it. What that gives up is an expanded instance that arrives without its rules attached; whether Stalwart does that is still to be checked against a real series.
This commit is contained in:
@@ -15,9 +15,9 @@ describe("isRecurring", () => {
|
|||||||
it("does not call a one-off event a series just because it has a baseEventId", () => {
|
it("does not call a one-off event a series just because it has a baseEventId", () => {
|
||||||
expect(isRecurring(ev({ baseEventId: "ev1" }))).toBe(false);
|
expect(isRecurring(ev({ baseEventId: "ev1" }))).toBe(false);
|
||||||
expect(isRecurring(ev({}))).toBe(false);
|
expect(isRecurring(ev({}))).toBe(false);
|
||||||
});
|
// The shape a live 0.16.19 returns for a one-off: an instance id of its own,
|
||||||
it("still recognises an occurrence whose base is another event", () => {
|
// and a base that is a different id. Neither makes it a series.
|
||||||
expect(isRecurring(ev({ id: "ev1_2", baseEventId: "ev1" }))).toBe(true);
|
expect(isRecurring(ev({ id: "eaaaaai", baseEventId: "i" }))).toBe(false);
|
||||||
});
|
});
|
||||||
it("recognises a series by its recurrence rules", () => {
|
it("recognises a series by its recurrence rules", () => {
|
||||||
expect(isRecurring(ev({ recurrenceRules: [{ "@type": "RecurrenceRule", frequency: "weekly" }] }))).toBe(true);
|
expect(isRecurring(ev({ recurrenceRules: [{ "@type": "RecurrenceRule", frequency: "weekly" }] }))).toBe(true);
|
||||||
|
|||||||
@@ -300,15 +300,15 @@ export const useCalendar = create<CalendarState>((set, get) => ({
|
|||||||
/**
|
/**
|
||||||
* Whether an event is part of a series.
|
* Whether an event is part of a series.
|
||||||
*
|
*
|
||||||
* Not the same question as "does it have a baseEventId": `CalendarEvent/query`
|
* Not the same question as "does it have a baseEventId", nor "is that base some
|
||||||
* runs with `expandRecurrences`, and Stalwart sets `baseEventId` on every event
|
* other event". `CalendarEvent/query` runs with `expandRecurrences`, and Stalwart
|
||||||
* it returns that way — a one-off event included, pointing at itself. Recurrence
|
* hands back an instance id for everything it returns that way — a one-off event
|
||||||
* rules are what make a series, so those are the question; a base that is some
|
* included, whose own id (`eaaaaai`) differs from its base (`i`), verified
|
||||||
* *other* event means this is one occurrence of one, whether or not the expanded
|
* against a live 0.16.19. Recurrence rules are what make a series, so those are
|
||||||
* instance carried the rules along with it.
|
* what we ask about.
|
||||||
*/
|
*/
|
||||||
export function isRecurring(ev: CalendarEvent): boolean {
|
export function isRecurring(ev: CalendarEvent): boolean {
|
||||||
return Boolean(ev.recurrenceRules?.length || ev.excludedRecurrenceRules?.length || (ev.baseEventId && ev.baseEventId !== ev.id));
|
return Boolean(ev.recurrenceRules?.length || ev.excludedRecurrenceRules?.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toInstance(e: CalendarEvent, calendars: Record<Id, Calendar>): EventInstance | null {
|
export function toInstance(e: CalendarEvent, calendars: Record<Id, Calendar>): EventInstance | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user