Skip to content

Commit

Permalink
feat: add client initialization component for preloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Orenoid committed Dec 7, 2024
1 parent 70b8e13 commit ffd5bb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/app/client-init.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client'

import { useEffect } from "react";
import { TTSTokenManager } from "./chat/lib/tts-token-manager";

export function ClientInit() {
useEffect(() => {
const initClient = async () => {
console.log('Client initialization started');
await TTSTokenManager.getInstance().getToken();
console.log('Client initialization completed');
};

initClient();
}, []);

return <></>;
}
4 changes: 4 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "./globals.css";
import Providers from "./providers";
import dynamic from 'next/dynamic';
import { PrimeReactProvider } from 'primereact/api';
import { ClientInit } from './client-init';


const geistSans = localFont({
Expand All @@ -28,18 +29,21 @@ export const metadata: Metadata = {
}
};


export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {

return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased h-screen w-screen`}
>
<I18nProvider>
<PrimeReactProvider>
<ClientInit />
<Providers>{children}</Providers>
</PrimeReactProvider>
</I18nProvider>
Expand Down

0 comments on commit ffd5bb7

Please sign in to comment.