改 state 为 reducer state, Context 共享数据修改, 完善资料卡对话框逻辑, 完善
This commit is contained in:
22
client/ui/routers/UserOrChatInfoDialogDataLoader.ts
Normal file
22
client/ui/routers/UserOrChatInfoDialogDataLoader.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { LoaderFunctionArgs } from "react-router"
|
||||
import getClient from "../../getClient"
|
||||
import { Chat } from "lingchair-client-protocol"
|
||||
|
||||
export default async function UserOrChatInfoDialogLoader({ params, request }: LoaderFunctionArgs) {
|
||||
const searchParams = new URL(request.url).searchParams
|
||||
|
||||
let id = searchParams.get('id')
|
||||
let chat: Chat
|
||||
if (params.type == 'user')
|
||||
chat = await Chat.getOrCreatePrivateChatOrThrow(getClient(), id!)
|
||||
else
|
||||
chat = await Chat.getByIdOrThrow(getClient(), id!)
|
||||
|
||||
if (chat.getType() == 'private')
|
||||
id = await chat.getTheOtherUserIdOrThrow()
|
||||
|
||||
return {
|
||||
chat,
|
||||
id,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user