diff options
| author | MohamedBassem <me@mbassem.com> | 2024-03-02 20:23:06 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-03-02 20:23:06 +0000 |
| commit | af87cc87f7319243cf42b87780f8eed26712d038 (patch) | |
| tree | dbf24dc54efd5849880a1113a1680f2df616657d /packages/web | |
| parent | 61252dad3c89dbca0d0f6edb3f7c599cd303e9e0 (diff) | |
| download | karakeep-af87cc87f7319243cf42b87780f8eed26712d038.tar.zst | |
ui: Preload the sidebar lists to avoid the spinner
Diffstat (limited to 'packages/web')
| -rw-r--r-- | packages/web/app/dashboard/components/AllLists.tsx | 11 | ||||
| -rw-r--r-- | packages/web/app/dashboard/components/Sidebar.tsx | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/packages/web/app/dashboard/components/AllLists.tsx b/packages/web/app/dashboard/components/AllLists.tsx index e2a6b777..c8b55d73 100644 --- a/packages/web/app/dashboard/components/AllLists.tsx +++ b/packages/web/app/dashboard/components/AllLists.tsx @@ -6,16 +6,15 @@ import LoadingSpinner from "@/components/ui/spinner"; import NewListModal, { useNewListModal } from "./NewListModal"; import { Plus } from "lucide-react"; import Link from "next/link"; +import { ZBookmarkList } from "@/lib/types/api/lists"; -export default function AllLists() { - const { data: lists } = api.lists.list.useQuery(); +export default function AllLists({initialData}: {initialData: {lists: ZBookmarkList[]}}) { + const { data: lists } = api.lists.list.useQuery(undefined, { + initialData, + }); const { setOpen } = useNewListModal(); - if (!lists) { - return <LoadingSpinner />; - } - return ( <ul className="max-h-full gap-y-2 overflow-auto text-sm font-medium"> <NewListModal /> diff --git a/packages/web/app/dashboard/components/Sidebar.tsx b/packages/web/app/dashboard/components/Sidebar.tsx index c6282a6b..a5c1d7a5 100644 --- a/packages/web/app/dashboard/components/Sidebar.tsx +++ b/packages/web/app/dashboard/components/Sidebar.tsx @@ -7,6 +7,7 @@ import SidebarProfileOptions from "./SidebarProfileOptions"; import { Separator } from "@/components/ui/separator"; import AllLists from "./AllLists"; import serverConfig from "@hoarder/shared/config"; +import { api } from "@/server/api/client"; export default async function Sidebar() { const session = await getServerAuthSession(); @@ -14,6 +15,8 @@ export default async function Sidebar() { redirect("/"); } + const lists = await api.lists.list(); + return ( <aside className="flex h-screen w-60 flex-col gap-5 border-r p-4"> <Link href={"/dashboard/bookmarks"}> @@ -53,7 +56,7 @@ export default async function Sidebar() { </ul> </div> <Separator /> - <AllLists /> + <AllLists initialData={lists} /> <div className="mt-auto flex justify-between justify-self-end"> <div className="my-auto"> {session.user.name} </div> <SidebarProfileOptions /> |
