Fix for bad primary calendar check (#7557)
parent
0c94b0a30a
commit
faaf935724
|
@ -44,7 +44,6 @@ export const getConnectedCalendars = async (
|
|||
calendarCredentials.map(async (item) => {
|
||||
try {
|
||||
const { calendar, integration, credential } = item;
|
||||
let primary!: IntegrationCalendar;
|
||||
|
||||
// Don't leak credentials to the client
|
||||
const credentialId = credential.id;
|
||||
|
@ -57,12 +56,7 @@ export const getConnectedCalendars = async (
|
|||
const cals = await calendar.listCalendars();
|
||||
const calendars = _(cals)
|
||||
.map((cal) => {
|
||||
if (cal.primary) {
|
||||
primary = { ...cal, credentialId };
|
||||
}
|
||||
if (cal.externalId === destinationCalendarExternalId) {
|
||||
destinationCalendar = cal;
|
||||
}
|
||||
if (cal.externalId === destinationCalendarExternalId) destinationCalendar = cal;
|
||||
return {
|
||||
...cal,
|
||||
readOnly: cal.readOnly || false,
|
||||
|
@ -73,11 +67,7 @@ export const getConnectedCalendars = async (
|
|||
})
|
||||
.sortBy(["primary"])
|
||||
.value();
|
||||
|
||||
if (primary && destinationCalendar) {
|
||||
destinationCalendar.primaryEmail = primary.email;
|
||||
destinationCalendar.integrationTitle = integration.title;
|
||||
}
|
||||
const primary = calendars.find((item) => item.primary) ?? calendars.find((cal) => cal !== undefined);
|
||||
if (!primary) {
|
||||
return {
|
||||
integration,
|
||||
|
@ -87,6 +77,10 @@ export const getConnectedCalendars = async (
|
|||
},
|
||||
};
|
||||
}
|
||||
if (destinationCalendar) {
|
||||
destinationCalendar.primaryEmail = primary.email;
|
||||
destinationCalendar.integrationTitle = integration.title;
|
||||
}
|
||||
|
||||
return {
|
||||
integration: cleanIntegrationKeys(integration),
|
||||
|
|
Loading…
Reference in New Issue