perf: Slim down logged in round 2 (#20535)

* perf: Slim down loggedInViewer some more

* Move locationOptions to apps router

* Moved calVideo related handlers to separate router

* Moved calendar related handlers to separate router

* Rename

* Moved deleteCredential to new router

* Moved updateProfile to me router

* fix unit test

* fix e2e test

* tweak

* missing

---------

Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: unknown <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-04-04 15:33:14 -04:00
1 parent 1953402f81
commit e86ad03cde
66 files changed
+240 -205

No files matched your search

@@ -84,16 +84,16 @@ export function CalendarListContainer(props: { heading?: boolean; fromOnboarding
exact: true,
}
),
utils.viewer.connectedCalendars.invalidate(),
utils.viewer.calendars.connectedCalendars.invalidate(),
]);
const query = trpc.viewer.connectedCalendars.useQuery();
const query = trpc.viewer.calendars.connectedCalendars.useQuery();
const installedCalendars = trpc.viewer.apps.integrations.useQuery({
variant: "calendar",
onlyInstalled: true,
});
const mutation = trpc.viewer.setDestinationCalendar.useMutation({
const mutation = trpc.viewer.calendars.setDestinationCalendar.useMutation({
onSuccess: () => {
utils.viewer.connectedCalendars.invalidate();
utils.viewer.calendars.connectedCalendars.invalidate();
},
});
return (
@@ -3,7 +3,7 @@ import { useState } from "react";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import type { AppRouter } from "@calcom/trpc/types/server/routers/_app";
import type { AppRouter } from "@calcom/trpc/server/routers/_app";
import { Button } from "@calcom/ui/components/button";
import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
import {
@@ -36,7 +36,7 @@ export function MultiDisconnectIntegration({ credentials, onSuccess }: Props) {
} | null>(null);
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
const mutation = trpc.viewer.deleteCredential.useMutation({
const mutation = trpc.viewer.credentials.delete.useMutation({
onSuccess: () => {
showToast(t("app_removed_successfully"), "success");
onSuccess && onSuccess();
@@ -47,7 +47,7 @@ export function MultiDisconnectIntegration({ credentials, onSuccess }: Props) {
setConfirmationDialogOpen(false);
},
async onSettled() {
await utils.viewer.connectedCalendars.invalidate();
await utils.viewer.calendars.connectedCalendars.invalidate();
await utils.viewer.apps.integrations.invalidate();
},
});
@@ -70,7 +70,7 @@ const LocationsWrapper = ({
};
const EventTypeConferencingAppSettings = ({ eventType, slug }: { eventType: TEventType; slug: string }) => {
const locationsQuery = trpc.viewer.locationOptions.useQuery({});
const locationsQuery = trpc.viewer.apps.locationOptions.useQuery({});
const { t } = useLocale();
const SkeletonLoader = () => {
@@ -92,7 +92,7 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
teamId,
} = props;
const { t } = useLocale();
const locationsQuery = trpc.viewer.locationOptions.useQuery({ teamId });
const locationsQuery = trpc.viewer.apps.locationOptions.useQuery({ teamId });
useEffect(() => {
if (selection) {
@@ -11,8 +11,10 @@ import { EditLocationDialog } from "../EditLocationDialog";
vi.mock("@calcom/trpc/react", () => ({
trpc: {
viewer: {
locationOptions: {
useQuery: vi.fn(),
apps: {
locationOptions: {
useQuery: vi.fn(),
},
},
},
},
@@ -4,14 +4,14 @@ import type { RouterInputs } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
interface ICreateEventsOnCalendarSelectProps {
calendar?: RouterInputs["viewer"]["setDestinationCalendar"] | null;
calendar?: RouterInputs["viewer"]["calendars"]["setDestinationCalendar"] | null;
}
const CreateEventsOnCalendarSelect = (props: ICreateEventsOnCalendarSelectProps) => {
const { calendar } = props;
const { t } = useLocale();
const mutation = trpc.viewer.setDestinationCalendar.useMutation();
const connectedCalendarsQuery = trpc.viewer.connectedCalendars.useQuery();
const mutation = trpc.viewer.calendars.setDestinationCalendar.useMutation();
const connectedCalendarsQuery = trpc.viewer.calendars.connectedCalendars.useQuery();
return (
<>
@@ -16,7 +16,7 @@ interface IConnectCalendarsProps {
const ConnectedCalendars = (props: IConnectCalendarsProps) => {
const { nextStep, isPageLoading } = props;
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery({
const queryConnectedCalendars = trpc.viewer.calendars.connectedCalendars.useQuery({
onboarding: true,
eventTypeId: null,
});
@@ -38,7 +38,7 @@ const UserProfile = () => {
const [firstRender, setFirstRender] = useState(true);
// Create a separate mutation for avatar updates
const avatarMutation = trpc.viewer.updateProfile.useMutation({
const avatarMutation = trpc.viewer.me.updateProfile.useMutation({
onSuccess: async (data) => {
showToast(t("your_user_profile_updated_successfully"), "success");
setImageSrc(data.avatarUrl ?? "");
@@ -49,7 +49,7 @@ const UserProfile = () => {
});
// Original mutation remains for onboarding completion
const mutation = trpc.viewer.updateProfile.useMutation({
const mutation = trpc.viewer.me.updateProfile.useMutation({
onSuccess: async () => {
try {
if (eventTypes?.length === 0) {
@@ -58,7 +58,7 @@ const UserSettings = (props: IUserSettingsProps) => {
await utils.viewer.me.invalidate();
nextStep();
};
const mutation = trpc.viewer.updateProfile.useMutation({
const mutation = trpc.viewer.me.updateProfile.useMutation({
onSuccess: onSuccess,
});
@@ -9,7 +9,7 @@ const DisableUserImpersonation = ({ disableImpersonation }: { disableImpersonati
const { t } = useLocale();
const mutation = trpc.viewer.updateProfile.useMutation({
const mutation = trpc.viewer.me.updateProfile.useMutation({
onSuccess: async () => {
showToast(t("your_user_profile_updated_successfully"), "success");
await utils.viewer.me.invalidate();
@@ -102,7 +102,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
checkUsername(debouncedUsername);
}, [debouncedUsername, currentUsername]);
const updateUsername = trpc.viewer.updateProfile.useMutation({
const updateUsername = trpc.viewer.me.updateProfile.useMutation({
onSuccess: async () => {
onSuccessMutation && (await onSuccessMutation());
await update({ username: inputUsernameValue });
@@ -70,7 +70,7 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.Component
checkUsername(debouncedUsername);
}, [debouncedUsername, currentUsername]);
const updateUsernameMutation = trpc.viewer.updateProfile.useMutation({
const updateUsernameMutation = trpc.viewer.me.updateProfile.useMutation({
onSuccess: async () => {
onSuccessMutation && (await onSuccessMutation());
setOpenDialogSaveUsername(false);