fix: improve video conference link positioning and null safety

- Fix calendarUtils.ts null safety for calendars[id] access
- Update video conference link to be added on line 2 instead of line 3
- Update regex in handleDeleteVideoConference to match new format
- Update all test cases for videoConferenceUtils to match new format
- Add null checks in updateCalsDetails function
This commit is contained in:
lenhanphung
2025-10-03 10:46:34 +07:00
parent ff54840ac8
commit cea576e5e8
4 changed files with 19 additions and 19 deletions
+13 -11
View File
@@ -74,7 +74,7 @@ export const extractEvents = (
) => { ) => {
let filteredEvents: CalendarEvent[] = []; let filteredEvents: CalendarEvent[] = [];
selectedCalendars.forEach((id) => { selectedCalendars.forEach((id) => {
if (calendars[id].events) { if (calendars[id] && calendars[id].events) {
filteredEvents = filteredEvents filteredEvents = filteredEvents
.concat( .concat(
Object.keys(calendars[id].events).map( Object.keys(calendars[id].events).map(
@@ -118,16 +118,18 @@ export const updateCalsDetails = (
if (rangeKey !== previousRangeKey) { if (rangeKey !== previousRangeKey) {
selectedCalendars?.forEach((id) => { selectedCalendars?.forEach((id) => {
dispatch( if (id) {
getCalendarDetailAsync({ dispatch(
calId: id, getCalendarDetailAsync({
match: { calId: id,
start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start), match: {
end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end), start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start),
}, end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end),
calType, },
}) calType,
); })
);
}
}); });
} }
}; };
+2 -4
View File
@@ -270,7 +270,7 @@ function EventPopover({
const handleDeleteVideoConference = () => { const handleDeleteVideoConference = () => {
// Remove video conference footer from description // Remove video conference footer from description
const updatedDescription = description.replace( const updatedDescription = description.replace(
/\n\nVisio: https?:\/\/[^\s]+/, /\nVisio: https?:\/\/[^\s]+/,
"" ""
); );
setDescription(updatedDescription); setDescription(updatedDescription);
@@ -500,7 +500,6 @@ function EventPopover({
/> />
} }
label="Mark as important" label="Mark as important"
sx={{ padding: "0 8px 0 0" }}
/> />
<FormControlLabel <FormControlLabel
control={ control={
@@ -534,7 +533,6 @@ function EventPopover({
/> />
} }
label="All day" label="All day"
sx={{ padding: "0 8px 0 0" }}
/> />
<FormControlLabel <FormControlLabel
control={ control={
@@ -596,7 +594,7 @@ function EventPopover({
</FieldWithLabel> </FieldWithLabel>
<FieldWithLabel label="Video meeting" isExpanded={showMore}> <FieldWithLabel label="Video meeting" isExpanded={showMore}>
<Box display="flex" gap={1} mb={1} alignItems="center"> <Box display="flex" gap={1} alignItems="center">
<Button <Button
startIcon={<VideocamIcon />} startIcon={<VideocamIcon />}
onClick={handleAddVideoConference} onClick={handleAddVideoConference}
@@ -49,7 +49,7 @@ describe("videoConferenceUtils", () => {
const description = ""; const description = "";
const meetingLink = "https://meet.linagora.com/abc-defg-hij"; const meetingLink = "https://meet.linagora.com/abc-defg-hij";
const result = addVideoConferenceToDescription(description, meetingLink); const result = addVideoConferenceToDescription(description, meetingLink);
expect(result).toBe("\n\nVisio: https://meet.linagora.com/abc-defg-hij"); expect(result).toBe("\nVisio: https://meet.linagora.com/abc-defg-hij");
}); });
it("should add video conference footer to existing description", () => { it("should add video conference footer to existing description", () => {
@@ -57,7 +57,7 @@ describe("videoConferenceUtils", () => {
const meetingLink = "https://meet.linagora.com/abc-defg-hij"; const meetingLink = "https://meet.linagora.com/abc-defg-hij";
const result = addVideoConferenceToDescription(description, meetingLink); const result = addVideoConferenceToDescription(description, meetingLink);
expect(result).toBe( expect(result).toBe(
"This is a meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij" "This is a meeting description.\nVisio: https://meet.linagora.com/abc-defg-hij"
); );
}); });
}); });
@@ -65,7 +65,7 @@ describe("videoConferenceUtils", () => {
describe("extractVideoConferenceFromDescription", () => { describe("extractVideoConferenceFromDescription", () => {
it("should extract video conference link from description", () => { it("should extract video conference link from description", () => {
const description = const description =
"Meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij"; "Meeting description.\nVisio: https://meet.linagora.com/abc-defg-hij";
const result = extractVideoConferenceFromDescription(description); const result = extractVideoConferenceFromDescription(description);
expect(result).toBe("https://meet.linagora.com/abc-defg-hij"); expect(result).toBe("https://meet.linagora.com/abc-defg-hij");
}); });
+1 -1
View File
@@ -42,7 +42,7 @@ export function addVideoConferenceToDescription(
description: string, description: string,
meetingLink: string meetingLink: string
): string { ): string {
const footer = `\n\nVisio: ${meetingLink}`; const footer = `\nVisio: ${meetingLink}`;
return description + footer; return description + footer;
} }