This repository was archived by the owner on Feb 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChatHistory.tsx
More file actions
62 lines (59 loc) · 1.59 KB
/
ChatHistory.tsx
File metadata and controls
62 lines (59 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { memo } from "react";
import { Flex, Box } from "@radix-ui/themes";
import { ScrollArea } from "../ScrollArea";
import { HistoryItem } from "./HistoryItem";
import {
getHistory,
type HistoryState,
} from "../../features/History/historySlice";
// import type { ChatThread } from "../../features/Chat/Thread/types";
export type ChatHistoryProps = {
history: HistoryState;
// onHistoryItemClick: (id: ChatThread) => void;
onDeleteHistoryItem: (id: string) => void;
onOpenChatInTab?: (id: string) => void;
currentChatId?: string;
};
// TODO: history item should be a nav link
export const ChatHistory = memo(
({
history,
// onHistoryItemClick,
onDeleteHistoryItem,
onOpenChatInTab,
currentChatId,
}: ChatHistoryProps) => {
const sortedHistory = getHistory({ history });
return (
<Box
style={{
overflow: "hidden",
}}
pb="2"
flexGrow="1"
>
<ScrollArea scrollbars="vertical">
<Flex
justify="center"
align="center"
pl="2"
pr="2"
direction="column"
>
{sortedHistory.map((item) => (
<HistoryItem
// onClick={() => onHistoryItemClick(item)}
onOpenInTab={onOpenChatInTab}
onDelete={onDeleteHistoryItem}
key={item.id}
historyItem={item}
disabled={item.id === currentChatId}
/>
))}
</Flex>
</ScrollArea>
</Box>
);
},
);
ChatHistory.displayName = "ChatHistory";