🔧 OPTIMIZATION: Implemented batch fetching for user and leak data in queries to resolve N+1 query issues, enhancing performance across multiple functions. Updated App component to remove blocking auth loading pattern for improved user experience.

This commit is contained in:
joaodunas
2025-12-21 14:45:43 +00:00
parent 44381858f8
commit ebd62cdeae
3 changed files with 161 additions and 152 deletions
+12 -11
View File
@@ -1,6 +1,6 @@
"use client";
import { Authenticated, Unauthenticated, useConvexAuth } from "convex/react";
import { Authenticated, Unauthenticated } from "convex/react";
import { useNavigate, Routes, Route, useLocation } from "react-router-dom";
import { Navbar } from "./components/navbar";
import Leaderboard from "./pages/Leaderboard";
@@ -11,21 +11,22 @@ import { LeakLibrary } from "./components/leakLibrary";
import { SubmitLeakForm } from "./components/submitLeakForm";
import Dashboard from "./pages/Dashboard";
/**
* Main App component.
*
* OPTIMIZATION: Removed the blocking auth loading pattern.
* Previously, the entire app would wait for authentication to complete before
* rendering anything, causing the "stuck" feeling on cold starts.
*
* Now, the app renders immediately and components handle their own loading states.
* The Authenticated/Unauthenticated components will automatically show/hide content
* based on auth state without blocking the entire UI.
*/
export default function App() {
const { isLoading } = useConvexAuth();
const navigate = useNavigate();
const location = useLocation();
const isHomePage = location.pathname === "/";
// Show only loading spinner during auth initialization
if (isLoading) {
return (
<div className="flex justify-center items-center h-screen bg-[#0f0f0f]">
<div className="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-[#00ff88]"></div>
</div>
);
}
return (
<>
<div className="min-h-screen bg-[#0f0f0f] text-[#e0e0e0] overflow-x-hidden font-sans relative">