fix: showing default apps by Cal like Cal-Video in installed apps (#10611)

Co-authored-by: Satya Nishanth <satya@Satyas-MacBook-Pro.local>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
feat/fix-mobile-availability^2
Satya Nishanth 2023-08-10 16:05:26 +05:30 committed by GitHub
parent 5f59ef2acf
commit 22b4bcdeeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -4,6 +4,8 @@ import { prisma } from "@calcom/prisma";
import type { Prisma } from ".prisma/client"; import type { Prisma } from ".prisma/client";
type EnabledApp = ReturnType<typeof getApps>[number] & { enabled: boolean };
/** /**
* *
* @param credentials - Can be user or team credentials * @param credentials - Can be user or team credentials
@ -39,14 +41,13 @@ const getEnabledApps = async (credentials: CredentialDataWithTeamName[], filterO
select: { slug: true, enabled: true }, select: { slug: true, enabled: true },
}); });
const apps = getApps(credentials, filterOnCredentials); const apps = getApps(credentials, filterOnCredentials);
const filteredApps = apps.reduce((reducedArray, app) => {
const filteredApps = enabledApps.reduce((reducedArray, app) => { const appDbQuery = enabledApps.find((metadata) => metadata.slug === app.slug);
const appMetadata = apps.find((metadata) => metadata.slug === app.slug); if (appDbQuery?.enabled || app.isGlobal) {
if (appMetadata) { reducedArray.push({ ...app, enabled: true });
reducedArray.push({ ...appMetadata, enabled: app.enabled });
} }
return reducedArray; return reducedArray;
}, [] as (ReturnType<typeof getApps>[number] & { enabled: boolean })[]); }, [] as EnabledApp[]);
return filteredApps; return filteredApps;
}; };