Skip to content

Commit

Permalink
Handles model changes for Advanced Repeat Rules
Browse files Browse the repository at this point in the history
Co-authored-by: André Dias <[email protected]>
  • Loading branch information
mup and andrehgdias committed Jan 8, 2025
1 parent 876438f commit a296edd
Show file tree
Hide file tree
Showing 25 changed files with 1,200 additions and 805 deletions.
2 changes: 1 addition & 1 deletion packages/node-mimimi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

0 comments on commit a296edd

Please sign in to comment.