Tweak data fetching with suspense

This commit is contained in:
Jared Palmer 2023-06-11 11:14:39 -04:00
parent f18e90289d
commit d087b429ee
5 changed files with 68 additions and 41 deletions

View file

@ -5,7 +5,11 @@ import { kv } from '@vercel/kv'
import { type Chat } from '@/lib/types'
export async function getChats(userId: string) {
export async function getChats(userId?: string | null) {
if (!userId) {
return []
}
try {
const pipeline = kv.pipeline()
const chats: string[] = await kv.zrange(`user:chat:${userId}`, 0, -1)