改 state 为 reducer state, Context 共享数据修改, 完善资料卡对话框逻辑, 完善

This commit is contained in:
CrescentLeaf
2025-12-13 18:05:09 +08:00
parent dee8a24f0b
commit 3351d7dc4e
7 changed files with 183 additions and 29 deletions

View 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,
}
}