Skip to content

Commit 842f10f

Browse files
add case for empty chat history
1 parent 759ec8c commit 842f10f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

components/sidebar-history.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
103103
isValidating,
104104
isLoading,
105105
mutate,
106-
error,
107106
} = useSWRInfinite<ChatHistory>(getChatHistoryPaginationKey, fetcher, {
108107
fallbackData: [],
109108
});
@@ -116,6 +115,10 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
116115
? paginatedChatHistories.some((page) => page.hasMore === false)
117116
: false;
118117

118+
const hasEmptyChatHistory = paginatedChatHistories
119+
? paginatedChatHistories.every((page) => page.chats.length === 0)
120+
: false;
121+
119122
const handleDelete = async () => {
120123
const deletePromise = fetch(`/api/chat?id=${deleteId}`, {
121124
method: 'DELETE',
@@ -186,7 +189,7 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
186189
);
187190
}
188191

189-
if (paginatedChatHistories?.length === 0) {
192+
if (hasEmptyChatHistory) {
190193
return (
191194
<SidebarGroup>
192195
<SidebarGroupContent>

0 commit comments

Comments
 (0)