diff --git a/packages/app-store/_appRegistry.ts b/packages/app-store/_appRegistry.ts index c7915da10f..d1a2103b34 100644 --- a/packages/app-store/_appRegistry.ts +++ b/packages/app-store/_appRegistry.ts @@ -1,5 +1,6 @@ import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData"; import prisma, { safeAppSelect, safeCredentialSelect } from "@calcom/prisma"; +import { userMetadata } from "@calcom/prisma/zod-utils"; import type { AppFrontendPayload as App } from "@calcom/types/App"; import type { CredentialFrontendPayload as Credential } from "@calcom/types/Credential"; @@ -61,8 +62,19 @@ export async function getAppRegistryWithCredentials(userId: number) { }, }, }); + const user = await prisma.user.findUnique({ + where: { + id: userId, + }, + select: { + metadata: true, + }, + }); + + const usersDefaultApp = userMetadata.parse(user?.metadata)?.defaultConferencingApp?.appSlug; const apps = [] as (App & { credentials: Credential[]; + isDefault?: boolean; })[]; for await (const dbapp of dbApps) { const app = await getAppWithMetadata(dbapp); @@ -70,7 +82,6 @@ export async function getAppRegistryWithCredentials(userId: number) { // Skip if app isn't installed /* This is now handled from the DB */ // if (!app.installed) return apps; - const { rating, reviews, trending, verified, ...remainingAppProps } = app; apps.push({ rating: rating || 0, @@ -81,6 +92,7 @@ export async function getAppRegistryWithCredentials(userId: number) { categories: dbapp.categories, credentials: dbapp.credentials, installed: true, + isDefault: usersDefaultApp === dbapp.slug, }); } return apps; diff --git a/packages/types/App.d.ts b/packages/types/App.d.ts index a632c0a82e..6c0c2bda98 100644 --- a/packages/types/App.d.ts +++ b/packages/types/App.d.ts @@ -142,6 +142,7 @@ export interface App { export type AppFrontendPayload = Omit & { /** We should type error if keys are leaked to the frontend */ + isDefault?: boolean; key?: never; }; diff --git a/packages/ui/components/apps/AppCard.tsx b/packages/ui/components/apps/AppCard.tsx index e3c7f92153..d32b3eaa58 100644 --- a/packages/ui/components/apps/AppCard.tsx +++ b/packages/ui/components/apps/AppCard.tsx @@ -149,7 +149,7 @@ export function AppCard({ app, credentials, searchText }: AppCardProps) { Template )} - {app.isGlobal && ( + {(app.isDefault || (!app.isDefault && app.isGlobal)) && ( {t("default")}