Skip to content

Commit

Permalink
Merge pull request #3 from vercel/shu/adda
Browse files Browse the repository at this point in the history
Add ISR
  • Loading branch information
shuding committed May 22, 2023
2 parents b33601d + 9b82554 commit dd9bcb7
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions app/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { type Session } from "@/lib/session/types";
import { cn } from "@/lib/utils";
import { Plus } from "lucide-react";
import Link from "next/link";
import { unstable_cache } from "next/cache";
import { SidebarItem } from "./sidebar-item";

export interface SidebarProps {
Expand Down Expand Up @@ -57,15 +58,25 @@ export function Sidebar({ session, newChat }: SidebarProps) {
Sidebar.displayName = "Sidebar";

async function SidebarList({ session }: { session?: Session }) {
const chats = await prisma.chat.findMany({
where: {
// This is for debugging, need to add scope to the query later
// userId: session?.user.id,
},
orderBy: {
updatedAt: "desc",
},
});
const chats = await (
await unstable_cache(
() =>
prisma.chat.findMany({
where: {
// This is for debugging, need to add scope to the query later
// userId: session?.user.id,
},
orderBy: {
updatedAt: "desc",
},
}),
[session?.user.id || ""],
{
revalidate: 3600,
}
)
)();

return chats.map((c) => (
<SidebarItem key={c.id} title={c.title} href={`/chat/${c.id}`} id={c.id} />
));
Expand Down

1 comment on commit dd9bcb7

@vercel
Copy link

@vercel vercel bot commented on dd9bcb7 May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

devgpt – ./

devgpt-git-main.vercel.sh
devgpt.vercel.sh

Please sign in to comment.