diff --git a/web/src/app/chat/page.tsx b/web/src/app/chat/page.tsx
index 4f91699b48c..05207ea9282 100644
--- a/web/src/app/chat/page.tsx
+++ b/web/src/app/chat/page.tsx
@@ -5,7 +5,6 @@ import { WelcomeModal } from "@/components/initialSetup/welcome/WelcomeModalWrap
import { ChatProvider } from "@/components/context/ChatContext";
import { fetchChatData } from "@/lib/chat/fetchChatData";
import WrappedChat from "./WrappedChat";
-import { AssistantsProvider } from "@/components/context/AssistantsContext";
export default async function Page({
searchParams,
diff --git a/web/src/app/layout.tsx b/web/src/app/layout.tsx
index e7e3c2c416d..6fd2799ab85 100644
--- a/web/src/app/layout.tsx
+++ b/web/src/app/layout.tsx
@@ -19,6 +19,7 @@ import { fetchAssistantData } from "@/lib/chat/fetchAssistantdata";
import { AppProvider } from "@/components/context/AppProvider";
import { PHProvider } from "./providers";
import { default as dynamicImport } from "next/dynamic";
+import { getCurrentUserSS } from "@/lib/userSS";
const PostHogPageView = dynamicImport(() => import("./PostHogPageView"), {
ssr: false,
@@ -57,7 +58,11 @@ export default async function RootLayout({
}: {
children: React.ReactNode;
}) {
- const combinedSettings = await fetchSettingsSS();
+ const [combinedSettings, assistantsData, user] = await Promise.all([
+ fetchSettingsSS(),
+ fetchAssistantData(),
+ getCurrentUserSS(),
+ ]);
const productGating =
combinedSettings?.settings.product_gating ?? GatingType.NONE;
@@ -165,11 +170,12 @@ export default async function RootLayout({
);
}
- const data = await fetchAssistantData();
- const { assistants, hasAnyConnectors, hasImageCompatibleModel } = data;
+ const { assistants, hasAnyConnectors, hasImageCompatibleModel } =
+ assistantsData;
return getPageContent(
{
return (
-
+
(undefined);
-export function UserProvider({ children }: { children: React.ReactNode }) {
- const [user, setUser] = useState(null);
- const [isLoadingUser, setIsLoadingUser] = useState(true);
- const [isAdmin, setIsAdmin] = useState(false);
- const [isCurator, setIsCurator] = useState(false);
+export function UserProvider({
+ children,
+ user,
+}: {
+ children: React.ReactNode;
+ user: User | null;
+}) {
+ const [upToDateUser, setUpToDateUser] = useState(user);
+ const [isLoadingUser, setIsLoadingUser] = useState(false);
const fetchUser = async () => {
try {
- const user = await getCurrentUser();
- setUser(user);
- setIsAdmin(user?.role === UserRole.ADMIN);
- setIsCurator(
- user?.role === UserRole.CURATOR || user?.role == UserRole.GLOBAL_CURATOR
- );
+ setIsLoadingUser(true);
+ const currentUser = await getCurrentUser();
+ setUpToDateUser(currentUser);
} catch (error) {
console.error("Error fetching current user:", error);
} finally {
@@ -35,17 +36,19 @@ export function UserProvider({ children }: { children: React.ReactNode }) {
}
};
- useEffect(() => {
- fetchUser();
- }, []);
-
const refreshUser = async () => {
await fetchUser();
};
return (
{children}