fix: handle collective multiple host on destinationCalendar#8
Conversation
| if (evt.location === MeetLocationType && evt.destinationCalendar?.integration !== "google_calendar") { | ||
| // @NOTE: destinationCalendar it's an array now so as a fallback we will only check the first one | ||
| const [mainHostDestinationCalendar] = evt.destinationCalendar ?? []; | ||
| if (evt.location === MeetLocationType && mainHostDestinationCalendar.integration !== "google_calendar") { |
There was a problem hiding this comment.
mainHostDestinationCalendar can be undefined when evt.destinationCalendar is null or empty, causing a runtime error when accessing .integration. Consider guarding this check to avoid throwing when no destination calendar is present.
🤖 Was this useful? React with 👍 or 👎
| const selectedCalendar = externalCalendarId | ||
| ? externalCalendarId | ||
| : event.destinationCalendar?.externalId; | ||
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; |
There was a problem hiding this comment.
When externalCalendarId is not provided, the fallback uses it in the predicate and will always yield undefined, leaving selectedCalendar unset. This can cause the update to target no calendar; consider a safe fallback (e.g., default or first destination).
🤖 Was this useful? React with 👍 or 👎
| const calendarId = externalCalendarId ? externalCalendarId : event.destinationCalendar?.externalId; | ||
| const calendarId = externalCalendarId | ||
| ? externalCalendarId | ||
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; |
There was a problem hiding this comment.
If externalCalendarId is absent, this fallback searches for it and will always return undefined, leaving calendarId unset for deletion. This can lead to delete failures; consider a default (e.g., primary or first destination) when no explicit ID is given.
🤖 Was this useful? React with 👍 or 👎
No description provided.