🐛 Fix double render for subscribed users (#877)

This commit is contained in:
Luke Vella 2023-09-19 17:36:35 +01:00 committed by GitHub
parent f64f9e9539
commit 0341f3a09b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import React from "react";
import { PostHogProvider } from "@/contexts/posthog";
import { useWhoAmI } from "@/contexts/whoami";
import { isSelfHosted } from "@/utils/constants";
import { useRequiredContext } from "./use-required-context";
@ -52,6 +53,11 @@ export const UserProvider = (props: { children?: React.ReactNode }) => {
const user = useWhoAmI();
const { data: userPreferences } = trpc.userPreferences.get.useQuery();
// TODO (Luke Vella) [2023-09-19]: Remove this when we have a better way to query for an active subscription
trpc.user.subscription.useQuery(undefined, {
enabled: !isSelfHosted,
});
const name = user
? user.isGuest === false
? user.name