feat: 从对话详情打开用户详情
This commit is contained in:
@@ -16,7 +16,10 @@ export type CallMethod =
|
||||
"User.getMyRecentChats" |
|
||||
|
||||
"Chat.getInfo" |
|
||||
|
||||
"Chat.getIdForPrivate" |
|
||||
"Chat.getAnotherUserIdFromPrivate" |
|
||||
|
||||
"Chat.sendMessage" |
|
||||
"Chat.getMessageHistory" |
|
||||
|
||||
|
||||
@@ -135,6 +135,12 @@ export default function App() {
|
||||
loginInputAccountRef={loginInputAccountRef}
|
||||
loginInputPasswordRef={loginInputPasswordRef} />
|
||||
|
||||
<ChatInfoDialog
|
||||
chatInfoDialogRef={chatInfoDialogRef as any}
|
||||
openChatFragment={openChatFragment}
|
||||
openUserInfoDialog={openUserInfoDialog}
|
||||
chat={chatInfo} />
|
||||
|
||||
<MyProfileDialog
|
||||
myProfileDialogRef={myProfileDialogRef as any}
|
||||
user={myUserProfileCache} />
|
||||
@@ -143,11 +149,6 @@ export default function App() {
|
||||
openChatFragment={openChatFragment}
|
||||
user={userInfo} />
|
||||
|
||||
<ChatInfoDialog
|
||||
chatInfoDialogRef={chatInfoDialogRef as any}
|
||||
openChatFragment={openChatFragment}
|
||||
chat={chatInfo} />
|
||||
|
||||
<AddContactDialog
|
||||
addContactDialogRef={addContactDialogRef} />
|
||||
|
||||
|
||||
@@ -156,6 +156,15 @@ export default function AppMobile() {
|
||||
loginInputAccountRef={loginInputAccountRef}
|
||||
loginInputPasswordRef={loginInputPasswordRef} />
|
||||
|
||||
<ChatInfoDialog
|
||||
chatInfoDialogRef={chatInfoDialogRef as any}
|
||||
openUserInfoDialog={openUserInfoDialog}
|
||||
openChatFragment={(id) => {
|
||||
setCurrentChatId(id)
|
||||
setIsShowChatFragment(true)
|
||||
}}
|
||||
chat={chatInfo} />
|
||||
|
||||
<MyProfileDialog
|
||||
myProfileDialogRef={myProfileDialogRef as any}
|
||||
user={myUserProfileCache} />
|
||||
@@ -164,14 +173,6 @@ export default function AppMobile() {
|
||||
openChatFragment={openChatFragment}
|
||||
user={userInfo} />
|
||||
|
||||
<ChatInfoDialog
|
||||
chatInfoDialogRef={chatInfoDialogRef as any}
|
||||
openChatFragment={(id) => {
|
||||
setCurrentChatId(id)
|
||||
setIsShowChatFragment(true)
|
||||
}}
|
||||
chat={chatInfo} />
|
||||
|
||||
<AddContactDialog
|
||||
addContactDialogRef={addContactDialogRef} />
|
||||
|
||||
|
||||
@@ -4,16 +4,18 @@ import useAsyncEffect from "../useAsyncEffect.ts"
|
||||
import Client from "../../api/Client.ts"
|
||||
import data from "../../Data.ts"
|
||||
import { Dialog } from "mdui"
|
||||
import Avatar from "../Avatar.tsx";
|
||||
import Avatar from "../Avatar.tsx"
|
||||
import { checkApiSuccessOrSncakbar } from "../snackbar.ts"
|
||||
import User from "../../api/client_data/User.ts"
|
||||
|
||||
interface Args extends React.HTMLAttributes<HTMLElement> {
|
||||
chat: Chat
|
||||
openChatFragment: (id: string) => void
|
||||
chatInfoDialogRef: React.MutableRefObject<Dialog>
|
||||
openUserInfoDialog: (user: User | string) => void
|
||||
}
|
||||
|
||||
export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragment }: Args) {
|
||||
export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragment, openUserInfoDialog }: Args) {
|
||||
const [chatInfo, setChatInfo] = React.useState(null as unknown as Chat)
|
||||
const isMySelf = Client.myUserProfile?.id == chatInfo?.user_a_id && Client.myUserProfile?.id == chatInfo?.user_b_id
|
||||
|
||||
@@ -45,14 +47,26 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
|
||||
</div>
|
||||
<mdui-divider style={{
|
||||
marginTop: "10px",
|
||||
marginBottom: "10px",
|
||||
}}></mdui-divider>
|
||||
|
||||
<mdui-list>
|
||||
{
|
||||
chat?.type == 'private' &&
|
||||
<mdui-list-item icon="person" rounded onClick={async () => {
|
||||
const re = await Client.invoke("Chat.getAnotherUserIdFromPrivate", {
|
||||
token: data.access_token,
|
||||
target: chat.id,
|
||||
})
|
||||
if (re.code != 200)
|
||||
return checkApiSuccessOrSncakbar(re, '获取用户失败')
|
||||
|
||||
openUserInfoDialog(re.data!.user_id as string)
|
||||
}}>用户详情</mdui-list-item>
|
||||
}
|
||||
<mdui-list-item icon="chat" rounded onClick={() => {
|
||||
chatInfoDialogRef.current!.open = false
|
||||
openChatFragment(chat.id)
|
||||
}}>對話</mdui-list-item>
|
||||
}}>打开此对话</mdui-list-item>
|
||||
</mdui-list>
|
||||
</mdui-dialog>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user