From bb0574dff88d1e435fb5fc1903748babc2bd864d Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Thu, 14 Sep 2023 08:56:31 -0400 Subject: [PATCH] chore: Outlook `processBusyTimes` iterate busy times once (#11350) --- .../app-store/office365calendar/lib/CalendarService.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/app-store/office365calendar/lib/CalendarService.ts b/packages/app-store/office365calendar/lib/CalendarService.ts index 5283eed719..ff28882c83 100644 --- a/packages/app-store/office365calendar/lib/CalendarService.ts +++ b/packages/app-store/office365calendar/lib/CalendarService.ts @@ -454,12 +454,13 @@ export default class Office365CalendarService implements Calendar { (acc: BufferedBusyTime[], subResponse: { body: { value?: BodyValue[]; error?: Error[] } }) => { if (!subResponse.body?.value) return acc; return acc.concat( - subResponse.body.value - .filter((evt) => evt.showAs !== "free" && evt.showAs !== "workingElsewhere") - .map((evt) => ({ + subResponse.body.value.reduce((acc: BufferedBusyTime[], evt: BodyValue) => { + if (evt.showAs === "free" || evt.showAs === "workingElsewhere") return acc; + return acc.concat({ start: evt.start.dateTime + "Z", end: evt.end.dateTime + "Z", - })) + }); + }, []) ); }, []