-
Notifications
You must be signed in to change notification settings - Fork 9.6k
perf: server side render settings/organizations/general #20833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…dling - Implement server-side session validation and redirection for unauthorized users. - Fetch current organization and user locale from the server. - Pass organization and user data to the LegacyPage component for improved rendering. - Refactor OrgGeneralView to accept props for current organization and user permissions.
@retrogtx is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 3 issues across 2 files. View them in mrge.io
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Outdated
Show resolved
Hide resolved
const ctx = await createContextInner({ session, locale: session.user.locale ?? "en" }); | ||
const caller = appRouter.createCaller(ctx); | ||
|
||
const user = await caller.viewer.me.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sequential API calls can be parallelized for better performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn you're right
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge reviewed 2 files and found no issues. Review this PR in mrge.io.
@@ -45,43 +42,22 @@ interface GeneralViewProps { | |||
localeProp: string; | |||
} | |||
|
|||
const OrgGeneralView = () => { | |||
interface OrgGeneralViewProps { | |||
currentOrg: NonNullable<RouterOutputs["viewer"]["organizations"]["listCurrent"]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonNullable - love it
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 1 issue across 2 files. View it in mrge.io
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Show resolved
Hide resolved
...app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/(main-page)/page.tsx
Outdated
Show resolved
Hide resolved
… unused components - Simplified the loading component import path. - Merged functionality from the deleted main-page into the general page for better organization. - Enhanced the page with server-side session handling and data fetching. - Removed obsolete skeleton and main-page files to streamline the codebase.
…page and header - Eliminated the Suspense component from the organization settings page and SettingsHeader to simplify rendering. - Streamlined the code by directly rendering child components without fallback loading states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 4 issues across 5 files. View them in mrge.io
|
||
export function SkeletonLoader() { | ||
const { t } = useLocale(); | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing aria-busy="true" attribute on the container element for better accessibility during loading states.
const { t } = useLocale(); | ||
return ( | ||
<SettingsHeader title={t("general")} description={t("general_description")} borderInShellHeader={true}> | ||
<div className="space-y-8 rounded-md border border-neutral-200 bg-white p-6 dark:border-neutral-700 dark:bg-neutral-900"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing role="status" attribute on the container for accessibility.
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Show resolved
Hide resolved
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Show resolved
Hide resolved
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 1 issue across 5 files. View it in mrge.io
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/general/page.tsx
Show resolved
Hide resolved
This PR is being marked as stale due to inactivity. |
@retrogtx Sorry for the delay! I will review tmrrow! please resolve conflicts btw! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few pointers:
-
I see that you have a skeleton UI for license key container as well. Is this needed? To my understanding, if license isn't there, user gets routed to /enterprise, anyways. So it is better to not have a skeleton UI for license key container to prevent a layout shift. Let me know if I am missing something here.
-
We are fetching the entire user object to get the locale only.
Rather, let's use:
const locale = (await getLocale(buildLegacyRequest(await headers(), await cookies()))) ?? "en";
- You need to create
actions.ts
and use revalidatePath to invalidate orgs data in this RSC whenever needed.
e.g., Search for how revalidateEventTypeEditPage
is used throughout the codebase
} | ||
|
||
const isAdminOrOwner = checkAdminOrOwner(session.user.org?.role); | ||
const localeProp = user?.locale ?? "en"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this available from session.user? please check that and if not, use getLocale
function as I mentioned above
What does this PR do?
useQuery
,useSession
) in theLegacyPage
component (packages/.../general.tsx
) to the server componentPage
(apps/web/.../general/page.tsx
).Page.tsx
using the tRPC caller (appRouter.createCaller
) to retrieve user and organization details.currentOrg
,isAdminOrOwner
,localeProp
) down as props to theLegacyPage
component.Removed redundant client-side data fetching hooks and related logic from the
LegacyPage
component.Screen.Recording.2025-04-24.at.10.54.39.AM.mov
Summary by mrge
Moved organization general settings data fetching from the client to the server for faster page loads and better security.