Skip to content

Commit 3d4a5a7

Browse files
committed
fix: group demo add rename func
1 parent e77ef17 commit 3d4a5a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/chat/demos/global-state/group.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
22
import { ThumbsUpOutlined } from '@dtinsight/react-icons';
33
import { Button } from 'antd';
44
import { Chat, Flex } from 'dt-react-component';
5+
import { produce } from 'immer';
56
import { cloneDeep } from 'lodash-es';
67

78
import { ConversationProperties } from '../../entity';
@@ -21,6 +22,13 @@ export default function () {
2122
};
2223

2324
const handleRenameChat = (_conversation: ConversationProperties, _value: string) => {
25+
setData((prev) => {
26+
const idx = prev.findIndex((i) => i.id === _conversation.id);
27+
if (idx === -1) return prev;
28+
return produce(prev, (draft) => {
29+
draft[idx].title = _value;
30+
});
31+
});
2432
return Promise.resolve(true);
2533
};
2634

0 commit comments

Comments
 (0)