Skip to main content

PSThreadList

Hiển thị danh sách các cuộc hội thoại của người dùng (1-1, nhóm,...)

Image of PSThreadList

Cách sử dụng

import {
PSChatProvider,
PSThreadList,
FEATURE_KEYS,
} from "@communi/chat-react";
import { useState } from "react";

export const App = () => {
const [threadId, setThreadId] = useState("");

const handleThreadChange = (threadId) => {
setThreadId(threadId);
// logic khi thread thay đổi
};

const config = {
features: {
[FEATURE_KEYS.TAG]: false, // Tắt hiển thị tag
[FEATURE_KEYS.CS_GROUP]: true, // Hiển thị các cuộc hội thoại cho CS team (tab inbox chung)
},
};

return (
<PSChatProvider>
<PSThreadList
className="ps-threadList"
style={{ width: 600 }}
threadId={threadId}
config={config}
onThreadSelected={handleThreadChange}
onSearchItemSelected={handleThreadChange}
onFrequentlyItemSelected={handleThreadChange}
/>
</PSChatProvider>
);
};

Props

Thuộc tínhMô tảKiểuBắt buộc
classNameTùy chỉnh class CSSstringKhông
styleTùy chỉnh style CSSobjectKhông
threadIdId của cuộc hội thoại hiện tạistringKhông
configCài đặt enable/disable các tính năng Xem chi tiếtobjectKhông
conversationIdTham số để xác định PSConversation hiện tại đang được liên kết với PSThreadList hay PSDeskInfo nào trong trường hợp vẽ nhiều PSConversation trên cùng một màn hình, các component được liên kết phải có cùng conversationIdstringKhông
isSearchOnlyJoinedThreadsChỉ cho phép tìm kiếm các cuộc hội thoại đã tham gia. Mặc định: falsebooleanKhông
onThreadSelectedHàm gọi lại khi một cuộc hội thoại được chọn để thực hiện các thao tác tuỳ chỉnhfunction(id: string)
onSearchItemSelectedHàm gọi lại khi một cuộc hội thoại trong tìm kiếm được chọn.function(id: string)
onFrequentlyItemSelectedHàm gọi lại khi một cuộc hội thoại gần đây được chọn.function(id: string)
renderCustomButtonsOfSearchBoxChỉnh sửa các button bên phải của thanh Search Xem ví dụ

Feature configs

KeyMô tả chức năngKiểuMặc định
FEATURE_KEYS.TAGHiển thị tag của cuộc hội thoạibooleantrue
FEATURE_KEYS.PERSONAL_THREADHiển thị tab Tin nhắnbooleantrue
FEATURE_KEYS.UNREAD_THREADHiển thị tab Chưa đọcbooleantrue
FEATURE_KEYS.PUBLIC_CHAT_LISTHiển thị tab Publicbooleantrue
FEATURE_KEYS.CS_GROUPHiển thị tab Inbox chungbooleanfalse
FEATURE_KEYS.LEAVE_THREADRời khỏi nhómbooleantrue
FEATURE_KEYS.REMOVE_THREADXóa cuộc hội thoại khỏi danh sáchbooleantrue
FEATURE_KEYS.SEARCH_THREADTìm kiếm các cuộc hội thoạibooleantrue
FEATURE_KEYS.CREATE_GROUPTạo nhóm chatbooleantrue
FEATURE_KEYS.CREATE_THREADTạo cuộc hội thoại mớibooleantrue

Tùy chỉnh các Button

Bạn có thể thay đổi các button bên phải của thanh Search bằng function renderCustomButtonsOfSearchBox

import { PSChatProvider, PSThreadList } from "@communi/chat-react";

const handleRenderCustomButtons = (defaultButtons) => {
// Modify the defaultButtons array, then return the newButtons array
const newButtons = [
...defaultButtons,
{
id: "foo",
icon: <div>foo</div>,
tooltip: "foo",
onClick: handleClickFooButton,
},
{
id: "bar",
icon: <div>bar</div>,
tooltip: "bar",
onClick: handleClickBarButton,
},
];
return newButtons;
};

export const App = () => {
return (
<PSChatProvider>
<PSThreadList
renderCustomButtonsOfSearchBox={handleRenderCustomButtons}
/>
</PSChatProvider>
);
};