From 8356cb7d344e91775d94acd56dff540867a2e5a4 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:19:26 -0400 Subject: [PATCH] Try to list calendars, if not continue (#10720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Omar López --- .../deleteCredential.handler.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts b/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts index f57439d7b8..4d676f9bfb 100644 --- a/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts +++ b/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts @@ -304,22 +304,26 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp // If it's a calendar remove it from the SelectedCalendars if (credential.app?.categories.includes(AppCategories.calendar)) { - const calendar = await getCalendar(credential); + try { + const calendar = await getCalendar(credential); - const calendars = await calendar?.listCalendars(); + const calendars = await calendar?.listCalendars(); - if (calendars && calendars.length > 0) { - calendars.map(async (cal) => { - await prisma.selectedCalendar.delete({ - where: { - userId_integration_externalId: { - userId: user.id, - externalId: cal.externalId, - integration: cal.integration as string, + if (calendars && calendars.length > 0) { + calendars.map(async (cal) => { + await prisma.selectedCalendar.delete({ + where: { + userId_integration_externalId: { + userId: user.id, + externalId: cal.externalId, + integration: cal.integration as string, + }, }, - }, + }); }); - }); + } + } catch { + console.log(`Error deleting selected calendars for user ${user.id} and calendar ${credential.appId}`); } }