Skip to content

Commit

Permalink
Merge pull request #39 from hive-one/fix-defaults
Browse files Browse the repository at this point in the history
use google meet or zoom as default
  • Loading branch information
rishimohan authored Nov 23, 2023
2 parents 20e2b14 + eeb73c8 commit 88700f9
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useEffect, useState } from "react";

import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
Expand All @@ -12,6 +14,7 @@ interface ConnectedAppStepProps {
}

const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
const [hasDefaultConferenceApp, setHasDefaultConferenceApp] = useState(false);
const { nextStep } = props;
const { data: queryConnectedVideoApps, isLoading } = trpc.viewer.integrations.useQuery({
variant: "conferencing",
Expand All @@ -23,9 +26,29 @@ const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
const hasAnyInstalledVideoApps = queryConnectedVideoApps?.items.some(
(item) => item.userCredentialIds.length > 0
);
const defaultConferencingApp = trpc.viewer.getUsersDefaultConferencingApp.useQuery();
const updateDefaultAppMutation = trpc.viewer.updateUserDefaultConferencingApp.useMutation();

const showConferencingApps = ["google-meet", "zoom"];

const setDefaultConferenceApp = () => {
queryConnectedVideoApps?.items?.map((item: any) => {
if (showConferencingApps.includes(item.slug) && item?.isInstalled) {
updateDefaultAppMutation.mutate({
appSlug: item.slug,
});

setHasDefaultConferenceApp(true);
}
});
};

useEffect(() => {
if (!hasDefaultConferenceApp) {
setDefaultConferenceApp();
}
}, [defaultConferencingApp, showConferencingApps]);

return (
<>
{!isLoading && (
Expand Down

0 comments on commit 88700f9

Please sign in to comment.