diff --git a/src/App.tsx b/src/App.tsx index 0c6a4cf..0268870 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -26,14 +26,15 @@ const App: Component = () => { onCleanup(() => removeListener()); - // Background preload of other views - setTimeout(() => { + // Background preload of other views when idle + const idleCallback = (window as any).requestIdleCallback || ((cb: any) => setTimeout(cb, 1000)); + idleCallback(() => { // CriticalView is now static import('./views/UrgencyView'); import('./views/PriorityView'); import('./views/MatrixView'); import('./views/SettingsView'); - }, 100); + }); }); return ( diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 85674f6..cd13aaf 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -19,11 +19,13 @@ export const Layout: Component = (props) => { const [isSidebarPeeking, setIsSidebarPeeking] = createSignal(false); onMount(() => { - // Preload TaskDetail and QuickEntry in background - setTimeout(() => { + // Preload heavy components in background when idle + const idleCallback = (window as any).requestIdleCallback || ((cb: any) => setTimeout(cb, 2000)); + idleCallback(() => { import("./TaskDetail"); import("./QuickEntry"); - }, 500); + import("./TaskEditor"); + }); }); // Derived active task for the detail view diff --git a/src/components/TaskDetail.tsx b/src/components/TaskDetail.tsx index 41276f1..13ce0e2 100644 --- a/src/components/TaskDetail.tsx +++ b/src/components/TaskDetail.tsx @@ -1,12 +1,14 @@ import { type Component, createEffect, createSignal } from "solid-js"; import { Sheet, SheetContent } from "@/components/ui/sheet"; import { type Task, removeTask, restoreTask, updateTask } from "@/store"; -import { TaskEditor } from "@/components/TaskEditor"; import { Select, SelectContent, SelectItem, SelectTrigger } from "@/components/ui/select"; import { ArrowUpCircle, Clock, Calendar, Type, Trash2 } from "lucide-solid"; import { calculateDateFromUrgency, calculateUrgencyFromDate } from "@/store"; import { Button } from "./ui/button"; import { toast } from "solid-sonner"; +import { lazy, Suspense } from "solid-js"; + +const TaskEditor = lazy(() => import("./TaskEditor").then(m => ({ default: m.TaskEditor }))); interface TaskDetailProps { task: Task; @@ -101,10 +103,10 @@ export const TaskDetail: Component = (props) => { val && updateUrgency(val)} + onChange={(val: string | null) => val && updateUrgency(val)} options={["10", "9", "8", "7", "6", "5", "4", "3", "2", "1"]} placeholder="Urgency" - itemComponent={(props) => {props.item.rawValue}} + itemComponent={(props: any) => {props.item.rawValue}} >
@@ -201,11 +203,13 @@ export const TaskDetail: Component = (props) => { {/* Editor Content */}
- + }> + +