Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

refactor: preload lazy chunks during auth init and clean up LoadingFallback props

Gabriel Stein435d9e4f1a94
diff --git a/src/components/AuthenticationStep.tsx b/src/components/AuthenticationStep.tsx
index 30ccaba7c..14c5cfa60 100644
--- a/src/components/AuthenticationStep.tsx
+++ b/src/components/AuthenticationStep.tsx
@@ -92,7 +92,8 @@ export default function AuthenticationStep({
}, []);
useEffect(() => {
- if (!isLoaded || !isSignedIn || needsVerificationRef.current || !user?.id || !user?.email) return;
+ if (!isLoaded || !isSignedIn || needsVerificationRef.current || !user?.id || !user?.email)
+ return;
const initAndComplete = async () => {
if (OPENWHISPR_API_URL) {
@@ -153,7 +154,9 @@ export default function AuthenticationStep({
const localPart = email.trim().split("@")[0];
if (localPart?.includes("+")) {
- setError("Email addresses containing \"+\" are not supported. Please use your original email address.");
+ setError(
+ 'Email addresses containing "+" are not supported. Please use your original email address.'
+ );
return;
}
diff --git a/src/main.jsx b/src/main.jsx
index 91feaa550..4780486e7 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -12,8 +12,10 @@ import { useTheme } from "./hooks/useTheme";
import { useAuth } from "./hooks/useAuth";
import "./index.css";
-const ControlPanel = React.lazy(() => import("./components/ControlPanel.tsx"));
-const OnboardingFlow = React.lazy(() => import("./components/OnboardingFlow.tsx"));
+const controlPanelImport = () => import("./components/ControlPanel.tsx");
+const onboardingFlowImport = () => import("./components/OnboardingFlow.tsx");
+const ControlPanel = React.lazy(controlPanelImport);
+const OnboardingFlow = React.lazy(onboardingFlowImport);
let root = null;
@@ -274,6 +276,16 @@ function AppRouter() {
window.location.pathname.includes("control") || window.location.search.includes("panel=true");
const isDictationPanel = !isControlPanel;
+ // Preload lazy chunks while waiting for auth so Suspense resolves instantly
+ useEffect(() => {
+ if (isControlPanel) {
+ controlPanelImport().catch(() => {});
+ if (!localStorage.getItem("onboardingCompleted")) {
+ onboardingFlowImport().catch(() => {});
+ }
+ }
+ }, [isControlPanel]);
+
useEffect(() => {
if (!authLoaded) return;
@@ -314,7 +326,7 @@ function AppRouter() {
};
if (isLoading) {
- return <LoadingFallback message="Loading OpenWhispr..." />;
+ return <LoadingFallback />;
}
// First-time user: full onboarding wizard
@@ -370,7 +382,7 @@ function AppRouter() {
);
}
-function LoadingFallback({ message }) {
+function LoadingFallback({ message = "Loading OpenWhispr..." }) {
return (
<div className="min-h-screen bg-background flex items-center justify-center">
<div className="flex flex-col items-center gap-4 animate-[scale-in_300ms_ease-out]">