Async import of the appStore packages#10
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the app store imports to use dynamic imports instead of static imports, enabling asynchronous loading of app packages. The changes propagate async/await patterns throughout the codebase where calendar, video, and payment app functionality is accessed.
Changes:
- Converted app store from static imports to dynamic imports using
import()statements - Updated all consumers of
getCalendar,getVideoAdapters, and app store access to useasync/await - Refactored
forEachloops tofor...ofloops where async operations are performed inside the iteration
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/app-store/index.ts | Replaced static imports with dynamic import() calls for all app modules |
| packages/app-store/_utils/getCalendar.ts | Made getCalendar function async to await app store module loading |
| packages/core/CalendarManager.ts | Updated calendar operations to await async getCalendar calls |
| packages/core/EventManager.ts | Added await to getCalendar call in event deletion |
| packages/core/videoClient.ts | Refactored video adapter functions to be async and use for...of loops |
| packages/trpc/server/routers/viewer/bookings.tsx | Added async/await to calendar and payment operations |
| packages/features/bookings/lib/handleNewBooking.ts | Updated calendar deletion to await async getCalendar |
| packages/features/bookings/lib/handleCancelBooking.ts | Converted forEach to for...of loop and added async/await for calendar operations |
| packages/lib/payment/handlePayment.ts | Added await to app store payment app access |
| packages/lib/payment/deletePayment.ts | Added await to app store payment app access |
| packages/app-store/wipemycalother/lib/reschedule.ts | Made forEach callback async for calendar deletion |
| packages/app-store/vital/lib/reschedule.ts | Made forEach callback async for calendar deletion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| bookingRefsFiltered.forEach(async (bookingRef) => { | ||
| if (bookingRef.uid) { | ||
| if (bookingRef.type.endsWith("_calendar")) { | ||
| const calendar = getCalendar(credentialsMap.get(bookingRef.type)); | ||
| const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); | ||
|
|
||
| return calendar?.deleteEvent( | ||
| bookingRef.uid, |
There was a problem hiding this comment.
Using an async callback within forEach creates a fire-and-forget scenario where the promises are not awaited. The deletion operations will not block execution and errors may go unhandled. Convert this to a for...of loop or use Promise.all with map to properly await all deletion operations.
| bookingRefsFiltered.forEach(async (bookingRef) => { | ||
| if (bookingRef.uid) { | ||
| if (bookingRef.type.endsWith("_calendar")) { | ||
| const calendar = getCalendar(credentialsMap.get(bookingRef.type)); | ||
| const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); | ||
| return calendar?.deleteEvent(bookingRef.uid, builder.calendarEvent); | ||
| } else if (bookingRef.type.endsWith("_video")) { | ||
| return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid); |
There was a problem hiding this comment.
Using an async callback within forEach creates a fire-and-forget scenario where the promises are not awaited. The deletion operations will not block execution and errors may go unhandled. Convert this to a for...of loop or use Promise.all with map to properly await all deletion operations.
| bookingRefsFiltered.forEach(async (bookingRef) => { | ||
| if (bookingRef.uid) { | ||
| if (bookingRef.type.endsWith("_calendar")) { | ||
| const calendar = getCalendar(credentialsMap.get(bookingRef.type)); | ||
| const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); | ||
| return calendar?.deleteEvent(bookingRef.uid, builder.calendarEvent); | ||
| } else if (bookingRef.type.endsWith("_video")) { | ||
| return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid); |
There was a problem hiding this comment.
Using an async callback within forEach creates a fire-and-forget scenario where the promises are not awaited. The deletion operations will not block execution and errors may go unhandled. Convert this to a for...of loop or use Promise.all with map to properly await all deletion operations.
Test 2nn
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.
nn---n*Replicated from [ai-code-review-evaluation/cal.com-coderabbit#2](https://github.com/ai-code-review-evaluation/cal.com-coderabbit/pull/2)*