mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-02 02:29:08 +00:00
Added persistance to sidebar state
This commit is contained in:
parent
658410d9e2
commit
544c75d6ad
2 changed files with 8 additions and 24 deletions
|
@ -1,5 +1,6 @@
|
||||||
"use client";
|
"use server";
|
||||||
|
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { DashboardBreadcrumb } from "@/components/dashboard-breadcrumb";
|
import { DashboardBreadcrumb } from "@/components/dashboard-breadcrumb";
|
||||||
import { AppSidebarProvider } from "@/components/sidebar/AppSidebarProvider";
|
import { AppSidebarProvider } from "@/components/sidebar/AppSidebarProvider";
|
||||||
|
@ -7,7 +8,7 @@ import { ThemeTogglerComponent } from "@/components/theme/theme-toggle";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
||||||
|
|
||||||
export function DashboardClientLayout({
|
export async function DashboardClientLayout({
|
||||||
children,
|
children,
|
||||||
searchSpaceId,
|
searchSpaceId,
|
||||||
navSecondary,
|
navSecondary,
|
||||||
|
@ -18,8 +19,11 @@ export function DashboardClientLayout({
|
||||||
navSecondary: any[];
|
navSecondary: any[];
|
||||||
navMain: any[];
|
navMain: any[];
|
||||||
}) {
|
}) {
|
||||||
|
const cookieStore = await cookies();
|
||||||
|
const defaultOpen = cookieStore.get("sidebar_state")?.value === "true";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarProvider>
|
<SidebarProvider defaultOpen={defaultOpen}>
|
||||||
{/* Use AppSidebarProvider which fetches user, search space, and recent chats */}
|
{/* Use AppSidebarProvider which fetches user, search space, and recent chats */}
|
||||||
<AppSidebarProvider
|
<AppSidebarProvider
|
||||||
searchSpaceId={searchSpaceId}
|
searchSpaceId={searchSpaceId}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { AlertCircle, Trash2 } from "lucide-react";
|
import { Trash2 } from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { AppSidebar } from "@/components/sidebar/app-sidebar";
|
import { AppSidebar } from "@/components/sidebar/app-sidebar";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
@ -50,26 +50,6 @@ interface AppSidebarProviderProps {
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading skeleton component
|
|
||||||
const LoadingSkeleton = () => (
|
|
||||||
<div className="space-y-2 p-2">
|
|
||||||
{Array.from({ length: 3 }).map((_, i) => (
|
|
||||||
<div key={i} className="h-8 bg-muted animate-pulse rounded-md" />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
// Error state component
|
|
||||||
const ErrorState = ({ error, onRetry }: { error: string; onRetry: () => void }) => (
|
|
||||||
<div className="p-4 text-center">
|
|
||||||
<AlertCircle className="h-8 w-8 text-destructive mx-auto mb-2" />
|
|
||||||
<p className="text-sm text-muted-foreground mb-2">{error}</p>
|
|
||||||
<Button variant="outline" size="sm" onClick={onRetry}>
|
|
||||||
Retry
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export function AppSidebarProvider({
|
export function AppSidebarProvider({
|
||||||
searchSpaceId,
|
searchSpaceId,
|
||||||
navSecondary,
|
navSecondary,
|
||||||
|
|
Loading…
Add table
Reference in a new issue