commit
dd9bcb7ab2
1 changed files with 20 additions and 9 deletions
|
|
@ -6,6 +6,7 @@ import { type Session } from "@/lib/session/types";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { Plus } from "lucide-react";
|
import { Plus } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { unstable_cache } from "next/cache";
|
||||||
import { SidebarItem } from "./sidebar-item";
|
import { SidebarItem } from "./sidebar-item";
|
||||||
|
|
||||||
export interface SidebarProps {
|
export interface SidebarProps {
|
||||||
|
|
@ -57,15 +58,25 @@ export function Sidebar({ session, newChat }: SidebarProps) {
|
||||||
Sidebar.displayName = "Sidebar";
|
Sidebar.displayName = "Sidebar";
|
||||||
|
|
||||||
async function SidebarList({ session }: { session?: Session }) {
|
async function SidebarList({ session }: { session?: Session }) {
|
||||||
const chats = await prisma.chat.findMany({
|
const chats = await (
|
||||||
where: {
|
await unstable_cache(
|
||||||
// This is for debugging, need to add scope to the query later
|
() =>
|
||||||
// userId: session?.user.id,
|
prisma.chat.findMany({
|
||||||
},
|
where: {
|
||||||
orderBy: {
|
// This is for debugging, need to add scope to the query later
|
||||||
updatedAt: "desc",
|
// userId: session?.user.id,
|
||||||
},
|
},
|
||||||
});
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
[session?.user.id || ""],
|
||||||
|
{
|
||||||
|
revalidate: 3600,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)();
|
||||||
|
|
||||||
return chats.map((c) => (
|
return chats.map((c) => (
|
||||||
<SidebarItem key={c.id} title={c.title} href={`/chat/${c.id}`} id={c.id} />
|
<SidebarItem key={c.id} title={c.title} href={`/chat/${c.id}`} id={c.id} />
|
||||||
));
|
));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue