diff --git a/src/components/loaders/database-loader.tsx b/src/components/loaders/database-loader.tsx index f28e3cf..1f263d9 100644 --- a/src/components/loaders/database-loader.tsx +++ b/src/components/loaders/database-loader.tsx @@ -1,6 +1,6 @@ "use client"; -import { createContext, useEffect, useState } from "react"; +import { createContext, ReactNode, useEffect, useState } from "react"; import Database, { db } from "../../common/database/database"; import FullscreenLoader from "./fullscreen-loader"; import { useToast } from "@/hooks/use-toast"; @@ -10,23 +10,27 @@ import { useToast } from "@/hooks/use-toast"; */ export const DatabaseContext = createContext(undefined); -type Props = { - children: React.ReactNode; +type DatabaseLoaderProps = { + /** + * The children to render. + */ + children: ReactNode; }; -export default function DatabaseLoader({ children }: Props) { +export default function DatabaseLoader({ children }: DatabaseLoaderProps) { const { toast } = useToast(); const [database, setDatabase] = useState(undefined); useEffect(() => { const before = performance.now(); setDatabase(db); - console.log(`Loaded database in ${performance.now() - before}ms`); db.on("ready", () => { + const loadTime = (performance.now() - before).toFixed(0); + console.log(`Loaded database in ${loadTime}ms`); toast({ title: "Database loaded", - description: `The database was loaded in ${performance.now() - before}ms.`, + description: `The database was loaded in ${loadTime}ms.`, }); }); }, [toast]);