Skip to content

Commit db73ef9

Browse files
committed
fix(meetings): handle string recurrence values from v1 meetings
In v1 meetings, recurrence pattern fields like type, monthly_week, and monthly_week_day are returned as strings instead of integers. This caused strict equality comparisons to fail. Added parseToInt() helper to handle both string and number inputs, and updated convertToRecurrencePattern() to parse all numeric fields before use. LFXV2-865 🤖 Generated with [Claude Code](https://claude.ai/code) Signed-off-by: Asitha de Silva <asithade@gmail.com>
1 parent 3e44a7b commit db73ef9

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

apps/lfx-one/src/app/shared/pipes/recurrence-summary.pipe.ts

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,33 @@ export class RecurrenceSummaryPipe implements PipeTransform {
2929
}
3030

3131
private convertToRecurrencePattern(recurrence: MeetingRecurrence): CustomRecurrencePattern {
32+
// Parse numeric values that might come as strings from v1 meetings
33+
// type defaults to 2 (weekly), repeat_interval defaults to 1
34+
const type = this.parseToInt(recurrence.type) ?? 2;
35+
const monthlyDay = this.parseToInt(recurrence.monthly_day);
36+
const monthlyWeek = this.parseToInt(recurrence.monthly_week);
37+
const monthlyWeekDay = this.parseToInt(recurrence.monthly_week_day);
38+
const endTimes = this.parseToInt(recurrence.end_times);
39+
const repeatInterval = this.parseToInt(recurrence.repeat_interval) ?? 1;
40+
3241
// Determine pattern type from recurrence.type
3342
let patternType: 'daily' | 'weekly' | 'monthly' = 'weekly';
34-
if (recurrence.type === 1) patternType = 'daily';
35-
else if (recurrence.type === 2) patternType = 'weekly';
36-
else if (recurrence.type === 3) patternType = 'monthly';
43+
if (type === 1) patternType = 'daily';
44+
else if (type === 2) patternType = 'weekly';
45+
else if (type === 3) patternType = 'monthly';
3746

3847
// Determine monthly type
3948
let monthlyType: 'dayOfMonth' | 'dayOfWeek' = 'dayOfMonth';
40-
if (recurrence.monthly_day) {
49+
if (monthlyDay) {
4150
monthlyType = 'dayOfMonth';
42-
} else if (recurrence.monthly_week && recurrence.monthly_week_day) {
51+
} else if (monthlyWeek && monthlyWeekDay) {
4352
monthlyType = 'dayOfWeek';
4453
}
4554

4655
// Determine end type
4756
let endType: 'never' | 'date' | 'occurrences' = 'never';
4857
if (recurrence.end_date_time) endType = 'date';
49-
else if (recurrence.end_times) endType = 'occurrences';
58+
else if (endTimes) endType = 'occurrences';
5059

5160
// Convert weekly_days to array if present
5261
let weeklyDaysArray: number[] = [];
@@ -56,10 +65,31 @@ export class RecurrenceSummaryPipe implements PipeTransform {
5665

5766
return {
5867
...recurrence,
68+
type,
69+
monthly_day: monthlyDay,
70+
monthly_week: monthlyWeek,
71+
monthly_week_day: monthlyWeekDay,
72+
end_times: endTimes,
73+
repeat_interval: repeatInterval,
5974
patternType,
6075
monthlyType,
6176
endType,
6277
weeklyDaysArray,
6378
};
6479
}
80+
81+
/**
82+
* Parse a value to integer, handling both string and number inputs.
83+
* Returns undefined if the value is undefined, null, or cannot be parsed.
84+
*/
85+
private parseToInt(value: string | number | undefined | null): number | undefined {
86+
if (value === undefined || value === null) {
87+
return undefined;
88+
}
89+
if (typeof value === 'number') {
90+
return value;
91+
}
92+
const parsed = parseInt(value, 10);
93+
return isNaN(parsed) ? undefined : parsed;
94+
}
6595
}

0 commit comments

Comments
 (0)