Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles model changes for Advanced Repeat Rules #8227

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions schemas/sys.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,16 @@
"info": "AddValue PlanConfiguration/unlimitedLabels/2494."
}
]
},
{
"version": 118,
"changes": [
{
"name": "AddAssociation",
"sourceType": "RepeatRule",
"info": "AddAssociation RepeatRule/advancedRules/AGGREGATION/2525."
}
]
}
]
}
10 changes: 10 additions & 0 deletions schemas/tutanota.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@
"info": "AddAssociation MailBox/mailImportStates/LIST_ASSOCIATION/1585."
}
]
},
{
"version": 80,
"changes": [
{
"name": "AddAssociation",
"sourceType": "CalendarRepeatRule",
"info": "AddAssociation CalendarRepeatRule/advancedRules/AGGREGATION/1590."
}
]
}
]
}
30 changes: 28 additions & 2 deletions src/calendar-app/calendar/export/CalendarParser.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { DAY_IN_MILLIS, filterInt, neverNull, Require } from "@tutao/tutanota-utils"
import { DateTime, Duration, IANAZone } from "luxon"
import type { CalendarEvent, EncryptedMailAddress } from "../../../common/api/entities/tutanota/TypeRefs.js"
import {
CalendarEvent,
CalendarEventAttendee,
createCalendarEvent,
createCalendarEventAttendee,
createEncryptedMailAddress,
EncryptedMailAddress,
} from "../../../common/api/entities/tutanota/TypeRefs.js"
import type { DateWrapper, RepeatRule } from "../../../common/api/entities/sys/TypeRefs.js"
import { CalendarAdvancedRepeatRule, createCalendarAdvancedRepeatRule, DateWrapper, RepeatRule } from "../../../common/api/entities/sys/TypeRefs.js"
import { createDateWrapper, createRepeatRule } from "../../../common/api/entities/sys/TypeRefs.js"
import type { Parser } from "../../../common/misc/parsing/ParserCombinator"
import {
Expand All @@ -30,6 +31,7 @@ import { CalendarAttendeeStatus, CalendarMethod, EndType, RepeatPeriod, reverse
import { AlarmInterval, AlarmIntervalUnit } from "../../../common/calendar/date/CalendarUtils.js"
import { AlarmInfoTemplate } from "../../../common/api/worker/facades/lazy/CalendarFacade.js"
import { serializeAlarmInterval } from "../../../common/api/common/utils/CommonCalendarUtils.js"
import { BYRULE_MAP } from "../../../common/calendar/import/ImportExportUtils.js"

function parseDateString(dateString: string): {
year: number
Expand Down Expand Up @@ -374,6 +376,7 @@ export function parseRrule(rawRruleValue: string, tzId: string | null): RepeatRu
frequency: frequency,
excludedDates: [],
timeZone: "",
advancedRules: parseAdvancedRule(rruleValue),
})

if (typeof tzId === "string") {
Expand All @@ -383,6 +386,29 @@ export function parseRrule(rawRruleValue: string, tzId: string | null): RepeatRu
return repeatRule
}

export function parseAdvancedRule(rrule: Record<string, string>): CalendarAdvancedRepeatRule[] {
const advancedRepeatRules: CalendarAdvancedRepeatRule[] = []
for (const rruleKey in rrule) {
if (!BYRULE_MAP.has(rruleKey)) {
continue
}

for (const interval of rrule[rruleKey].split(",")) {
if (interval === "") {
continue
}

advancedRepeatRules.push(
createCalendarAdvancedRepeatRule({
ruleType: BYRULE_MAP.get(rruleKey)!.toString(),
interval,
}),
)
}
}
return advancedRepeatRules
}

export function parseExDates(excludedDatesProps: Property[]): DateWrapper[] {
// it's possible that we have duplicated entries since this data comes from whereever, this deduplicates it.
const allExDates: Map<number, DateWrapper> = new Map<number, DateWrapper>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export class CalendarEventWhenModel {
frequency: RepeatPeriod.DAILY,
excludedDates: [],
timeZone: "",
advancedRules: [],
})
this.repeatRule.frequency = repeatPeriod
}
Expand Down Expand Up @@ -479,6 +480,7 @@ export class CalendarEventWhenModel {
endValue: null,
interval: "0",
frequency: "0",
advancedRules: [],
}),
...this.repeatRule,
timeZone: this.zone,
Expand Down
4 changes: 2 additions & 2 deletions src/common/api/entities/sys/ModelInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const modelInfo = {
version: 117,
compatibleSince: 114,
version: 118,
compatibleSince: 118,
}

export default modelInfo
Loading
Loading