feat: 删除群成员组
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { $ } from "mdui/jq"
|
||||
import { $, dialog } from "mdui"
|
||||
import Avatar from "../Avatar.tsx"
|
||||
import React from 'react'
|
||||
import User from "../../api/client_data/User.ts"
|
||||
@@ -9,7 +9,7 @@ interface Args extends React.HTMLAttributes<HTMLElement> {
|
||||
}
|
||||
|
||||
export default function GroupMembersListItem({ user }: Args) {
|
||||
const { nickname, avatar_file_hash } = user
|
||||
const { id, nickname, avatar_file_hash } = user
|
||||
|
||||
const itemRef = React.useRef<HTMLElement>(null)
|
||||
return (
|
||||
@@ -19,10 +19,52 @@ export default function GroupMembersListItem({ user }: Args) {
|
||||
}} ref={itemRef}>
|
||||
{nickname}
|
||||
<Avatar src={getUrlForFileByHash(avatar_file_hash)} text={nickname} slot="icon" />
|
||||
{/* <div slot="end-icon">
|
||||
<mdui-button-icon icon="check"></mdui-button-icon>
|
||||
<mdui-button-icon icon="delete"></mdui-button-icon>
|
||||
</div> */}
|
||||
<div slot="end-icon">
|
||||
<mdui-button-icon icon="delete" onClick={() => dialog({
|
||||
headline: "移除群组成员",
|
||||
description: `确定要移除 ${nickname} 吗?`,
|
||||
actions: [
|
||||
{
|
||||
text: "取消",
|
||||
onClick: () => {
|
||||
return true
|
||||
},
|
||||
},
|
||||
{
|
||||
text: "确定",
|
||||
onClick: () => {
|
||||
;(async () => {
|
||||
const re = await Client.invoke("Chat.removeMembers", {
|
||||
token: data.access_token,
|
||||
chat_id: target,
|
||||
user_ids: [
|
||||
id
|
||||
],
|
||||
})
|
||||
if (re.code != 200)
|
||||
checkApiSuccessOrSncakbar(re, "移除群组成员失败")
|
||||
EventBus.emit('GroupMembersList.updateMembers')
|
||||
snackbar({
|
||||
message: `已移除 ${nickname}`,
|
||||
placement: "top",
|
||||
action: "撤销操作",
|
||||
onActionClick: async () => {
|
||||
const re = await Client.invoke("User.addContacts", {
|
||||
token: data.access_token,
|
||||
targets: ls,
|
||||
})
|
||||
if (re.code != 200)
|
||||
checkApiSuccessOrSncakbar(re, "恢复所选收藏失败")
|
||||
EventBus.emit('ContactsList.updateContacts')
|
||||
}
|
||||
})
|
||||
})()
|
||||
return true
|
||||
},
|
||||
}
|
||||
],
|
||||
})}></mdui-button-icon>
|
||||
</div>
|
||||
</mdui-list-item>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user