Skip to content

Scheduling infrastructure for absolutely everyone.

Attempt to fix duplicate webhooks

zomars7d277ad89f53
diff --git a/packages/features/webhooks/components/WebhookForm.tsx b/packages/features/webhooks/components/WebhookForm.tsx
index f9b52fedd31..df07ac159bc 100644
--- a/packages/features/webhooks/components/WebhookForm.tsx
+++ b/packages/features/webhooks/components/WebhookForm.tsx
@@ -1,5 +1,5 @@
import { WebhookTriggerEvents } from "@prisma/client";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { classNames } from "@calcom/lib";
@@ -47,14 +47,18 @@ const WebhookForm = (props: {
apps?: (keyof typeof WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2)[];
onSubmit: (event: WebhookFormSubmitData) => void;
}) => {
+ const { apps = [] } = props;
const { t } = useLocale();
+ const triggerOptions = useMemo(
+ () =>
+ apps.reduce((acc, app) => {
+ if (!WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2[app]) return acc;
+ acc.push(...WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2[app]);
+ return acc;
+ }, WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2["core"]),
+ [apps]
+ );
- const triggerOptions: WebhookTriggerEventOptions = WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2["core"];
- if (props.apps) {
- for (const app of props.apps) {
- triggerOptions.push(...WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2[app]);
- }
- }
const translatedTriggerOptions = triggerOptions.map((option) => ({ ...option, label: t(option.label) }));
const formMethods = useForm({
diff --git a/packages/features/webhooks/pages/webhook-new-view.tsx b/packages/features/webhooks/pages/webhook-new-view.tsx
index 0bfed41e7b8..35ac4e895a8 100644
--- a/packages/features/webhooks/pages/webhook-new-view.tsx
+++ b/packages/features/webhooks/pages/webhook-new-view.tsx
@@ -13,7 +13,6 @@ const NewWebhookView = () => {
const { t } = useLocale();
const utils = trpc.useContext();
const router = useRouter();
- // const appId = props.app;
const { data: installedApps, isLoading } = trpc.useQuery(
["viewer.integrations", { variant: "other", onlyInstalled: true }],
{