ContactList State

ContactListState 是基于 Zustand 的关系链管理钩子,为 ContactLis 组件提供完整的数据管理能力。它支持好友列表、群组列表、黑名单和申请管理等功能关了。如果自定义组件能力不能支持您的业务,可以使用 ContactListState 实现您的需求。

数据

属性名
类型
说明
friendList
Friend[]
好友列表
groupList
Group[]
群组列表
blackList
UserProfile[]
黑名单列表
friendApplicationUnreadCount
number
未读好友申请数量
friendGroupList
FriendGroup[]
好友分组列表
friendApplicationList
FriendApplication[]
好友申请列表
groupApplicationList
GroupApplication[]
群组申请列表

操作方法

属性名
类型
说明
addFriend
(options: AddFriendParams) => Promise
添加好友
deleteFriend
(options: DeleteFriendParams) => Promise
删除好友
setFriendRemark
(options: FriendRemarkParams) => Promise
设置好友备注
markFriendApplicationAsRead
() => Promise
标记好友申请为已读
acceptFriendApplication
(options: FriendApplicationParams) => Promise
接受好友申请
refuseFriendApplication
(userID: string) => Promise
拒绝好友申请
addToBlacklist
(userIDList: string[]) => Promise
添加到黑名单
removeFromBlacklist
(userIDList: string[]) => Promise
从黑名单移除
createFriendGroup
(options: FriendGroupParams) => Promise
创建好友分组
deleteFriendGroup
(name: string) => Promise
删除好友分组
addToFriendGroup
(options: FriendGroupParams) => Promise
添加好友到分组
removeFromFriendGroup
(options: FriendGroupParams) => Promise
从分组移除好友
renameFriendGroup
(options: RenameFriendGroupParams) => Promise
重命名好友分组
joinGroup
(options: JoinGroupParams) => Promise
申请加入群组
acceptGroupApplication
(options: GroupApplicationParams) => Promise
接受群组申请
refuseGroupApplication
(options: GroupApplicationParams) => Promise
拒绝群组申请

使用示例

import { useContactListState } from '@tencentcloud/chat-uikit-react';
const {
friendList,
groupList,
blackList,
friendApplicationUnreadCount,
friendGroupList,
friendApplicationList,
groupApplicationList,
addFriend,
deleteFriend,
setFriendRemark,
markFriendApplicationAsRead,
acceptFriendApplication,
refuseFriendApplication,
addToBlacklist,
removeFromBlacklist,
createFriendGroup,
deleteFriendGroup,
addToFriendGroup,
removeFromFriendGroup,
joinGroup,
acceptGroupApplication,
refuseGroupApplication,
} = useContactListState();