diff --git a/client/ui/dialog/ChatInfoDialog.tsx b/client/ui/dialog/ChatInfoDialog.tsx
index 090ec20..9529733 100644
--- a/client/ui/dialog/ChatInfoDialog.tsx
+++ b/client/ui/dialog/ChatInfoDialog.tsx
@@ -3,7 +3,7 @@ import Chat from "../../api/client_data/Chat.ts"
import useAsyncEffect from "../useAsyncEffect.ts"
import Client from "../../api/Client.ts"
import data from "../../Data.ts"
-import { Dialog } from "mdui"
+import { dialog, Dialog } from "mdui"
import Avatar from "../Avatar.tsx"
import { checkApiSuccessOrSncakbar } from "../snackbar.ts"
import User from "../../api/client_data/User.ts"
@@ -33,8 +33,7 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
return checkApiSuccessOrSncakbar(re, '获取对话信息失败')
const info = re.data as Chat
- setChatInfo(info)
- setIsFavourited(sharedFavouriteChats.indexOf(info) != -1)
+ setIsFavourited(sharedFavouriteChats.map((v) => v.id).indexOf(info.id) != -1)
}, [chat, sharedFavouriteChats])
const avatarUrl = getUrlForFileByHash(chat?.avatar_file_hash as string)
@@ -71,21 +70,39 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
openUserInfoDialog(re.data!.user_id as string)
}}>用户详情
}
- {
- const re = await Client.invoke(favourited ? "User.removeContacts" : "User.addContacts", {
- token: data.access_token,
- targets: [
- chat.id
- ],
- })
- if (re.code != 200)
- checkApiSuccessOrSncakbar(re, favourited ? "取消收藏失败" : "收藏失败")
- EventBus.emit('ContactsList.updateContacts')
- }}>{favourited ? '取消收藏' : '收藏对话'}
+ dialog({
+ headline: favourited ? "取消收藏对话" : "收藏对话",
+ description: favourited ? "确定从收藏对话列表中移除吗? (虽然这不会导致聊天记录丢失)" : "确定要添加到收藏对话列表吗?",
+ actions: [
+ {
+ text: "取消",
+ onClick: () => {
+ return true
+ },
+ },
+ {
+ text: "确定",
+ onClick: () => {
+ ;(async () => {
+ const re = await Client.invoke(favourited ? "User.removeContacts" : "User.addContacts", {
+ token: data.access_token,
+ targets: [
+ chat.id
+ ],
+ })
+ if (re.code != 200)
+ checkApiSuccessOrSncakbar(re, favourited ? "取消收藏失败" : "收藏失败")
+ EventBus.emit('ContactsList.updateContacts')
+ })()
+ return true
+ },
+ }
+ ],
+ })}>{favourited ? '取消收藏' : '收藏对话'}
{
chatInfoDialogRef.current!.open = false
openChatFragment(chat.id)
- }}>打开此对话
+ }}>打开对话
)