Skip to content

An AI-powered search engine with a generative UI

Fix async issue in Header component and pass chats to History component

Yoshiki Miurabf7f33427fbb
diff --git a/components/header.tsx b/components/header.tsx
index 144665ad..d64ee57e 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -1,12 +1,13 @@
-'use client'
-
import React from 'react'
import { ModeToggle } from './mode-toggle'
import { IconLogo } from './ui/icons'
import { cn } from '@/lib/utils'
+import { cache } from 'react'
import { History } from './history'
+import { getChats } from '@/lib/actions/chat'
-export const Header: React.FC = () => {
+export const Header: React.FC = async () => {
+ const chats = await getChats('anonymous')
return (
<header className="fixed w-full p-1 md:p-2 flex justify-between items-center z-10 backdrop-blur md:backdrop-blur-none bg-background/80 md:bg-transparent">
<div>
@@ -18,7 +19,7 @@ export const Header: React.FC = () => {
<div className="flex gap-0.5">
<ModeToggle />
<div className="sm:hidden block">
- <History location="header" />
+ <History location="header" chats={chats} />
</div>
</div>
</header>
diff --git a/components/history-item.tsx b/components/history-item.tsx
index 0d8f3ee6..ea7a3b29 100644
--- a/components/history-item.tsx
+++ b/components/history-item.tsx
@@ -16,7 +16,7 @@ const formatDateWithTime = (date: Date | string) => {
const yesterday = new Date()
yesterday.setDate(yesterday.getDate() - 1)
- const formatTime = date => {
+ const formatTime = (date: Date) => {
return date.toLocaleString('en-US', {
hour: '2-digit',
minute: '2-digit',