个人资料卡的一些修改

This commit is contained in:
CrescentLeaf
2025-12-13 18:17:27 +08:00
parent 8fbf84d5dc
commit ae0e7fee95
3 changed files with 47 additions and 33 deletions

View File

@@ -17,7 +17,9 @@ export default function UserOrChatInfoDialog() {
}))
const dialogRef = useRouterDialogRef()
const { chat, id } = useLoaderData<typeof UserOrChatInfoDialogLoader>()
const { chat, id, mySelf } = useLoaderData<typeof UserOrChatInfoDialogLoader>()
const isMySelf = mySelf?.getId() == id
const favourited = React.useMemo(() => shared.state.favouriteChats.map((v) => v.getId()).indexOf(chat.getId() || '') != -1, [chat, shared.state.favouriteChats])
@@ -53,37 +55,44 @@ export default function UserOrChatInfoDialog() {
marginTop: "10px",
}}></mdui-divider>
<mdui-list>
<mdui-list-item icon={favourited ? "favorite_border" : "favorite"} rounded onClick={() => dialog({
headline: favourited ? "取消收藏对话" : "收藏对话",
description: favourited ? "确定从收藏对话列表中移除吗? (虽然这不会导致聊天记录丢失)" : "确定要添加到收藏对话列表吗?",
actions: [
{
text: "取消",
onClick: () => {
return true
{
isMySelf && <mdui-list-item icon="edit" rounded>
</mdui-list-item>
}
{
!isMySelf && <mdui-list-item icon={favourited ? "favorite_border" : "favorite"} rounded onClick={() => dialog({
headline: favourited ? "取消收藏对话" : "收藏对话",
description: favourited ? "确定从收藏对话列表中移除吗? (虽然这不会导致聊天记录丢失)" : "确定要添加到收藏对话列表吗?",
actions: [
{
text: "取消",
onClick: () => {
return true
},
},
},
{
text: "确定",
onClick: () => {
; (async () => {
try {
if (favourited)
await (await ClientCache.getMySelf())!.removeFavouriteChatsOrThrow([chat.getId()])
else
await (await ClientCache.getMySelf())!.addFavouriteChatsOrThrow([chat.getId()])
} catch (e) {
if (e instanceof CallbackError)
showSnackbar({
message: (favourited ? "取消收藏对话" : "收藏对话") + '失败: ' + e.message
})
}
})()
return true
},
}
],
})}>{favourited ? '取消收藏' : '收藏对话'}</mdui-list-item>
{
text: "确定",
onClick: () => {
; (async () => {
try {
if (favourited)
await (await ClientCache.getMySelf())!.removeFavouriteChatsOrThrow([chat.getId()])
else
await (await ClientCache.getMySelf())!.addFavouriteChatsOrThrow([chat.getId()])
} catch (e) {
if (e instanceof CallbackError)
showSnackbar({
message: (favourited ? "取消收藏对话" : "收藏对话") + '失败: ' + e.message
})
}
})()
return true
},
}
],
})}>{favourited ? '取消收藏' : '收藏对话'}</mdui-list-item>
}
<mdui-list-item icon="chat" rounded onClick={() => {
}}></mdui-list-item>