From ae518a2f368a5adb03d263a95f9b028640ae1cb2 Mon Sep 17 00:00:00 2001 From: sijinhui Date: Wed, 25 Sep 2024 00:03:25 +0800 Subject: [PATCH] add --- app/components/chat-list.tsx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app/components/chat-list.tsx b/app/components/chat-list.tsx index c562e5eb1..03708c130 100644 --- a/app/components/chat-list.tsx +++ b/app/components/chat-list.tsx @@ -5,6 +5,7 @@ import { Droppable, Draggable, OnDragEndResponder, + DraggableProvided, } from "@hello-pangea/dnd"; import { useChatStore } from "../store"; @@ -32,7 +33,7 @@ export function ChatItem(props: { index: number; narrow?: boolean; mask: Mask; - provided; + provided: DraggableProvided; }) { const draggableRef = useRef(null); useEffect(() => { @@ -108,7 +109,6 @@ export function ChatList(props: { narrow?: boolean }) { const chatStore = useChatStore(); const navigate = useNavigate(); const isMobileScreen = useMobileScreen(); - const onDragEnd: OnDragEndResponder = (result) => { const { destination, source } = result; if (!destination) { @@ -125,6 +125,30 @@ export function ChatList(props: { narrow?: boolean }) { moveSession(source.index, destination.index); }; + const onAdd = () => { + const { data } = this.state; + const i = Math.floor(Math.random() * this.data.length); + data.unshift({ + key: Date.now(), + name: this.data[i].name, + age: this.data[i].age, + address: this.data[i].address, + }); + this.setState({ + data, + isPageTween: false, + }); + }; + + const onDelete = ( + key: number, + e: React.MouseEvent, + ) => { + e.preventDefault(); + const data = this.state.data.filter((item) => item.key !== key); + this.setState({ data, isPageTween: false }); + }; + return ( {sessions.map((item, i) => (