Merge branch 'main' into feat/fix-mobile-availability

feat/fix-mobile-availability
Peer Richelsen 2023-08-10 14:14:51 +02:00 committed by GitHub
commit c9c2c2f2dc
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";
type EnabledApp = ReturnType<typeof getApps>[number] & { enabled: boolean };
/**
*
* @param credentials - Can be user or team credentials
@ -39,14 +41,13 @@ const getEnabledApps = async (credentials: CredentialDataWithTeamName[], filterO
select: { slug: true, enabled: true },
});
const apps = getApps(credentials, filterOnCredentials);
const filteredApps = enabledApps.reduce((reducedArray, app) => {
const appMetadata = apps.find((metadata) => metadata.slug === app.slug);
if (appMetadata) {
reducedArray.push({ ...appMetadata, enabled: app.enabled });
const filteredApps = apps.reduce((reducedArray, app) => {
const appDbQuery = enabledApps.find((metadata) => metadata.slug === app.slug);
if (appDbQuery?.enabled || app.isGlobal) {
reducedArray.push({ ...app, enabled: true });
}
return reducedArray;
}, [] as (ReturnType<typeof getApps>[number] & { enabled: boolean })[]);
}, [] as EnabledApp[]);
return filteredApps;
};