改 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

@@ -1,9 +1,17 @@
import { Chat, User } from "lingchair-client-protocol"
import { Chat, User, UserMySelf } from "lingchair-client-protocol"
import getClient from "./getClient"
type CouldCached = User | Chat | null
export default class ClientCache {
static caches: { [key: string]: CouldCached } = {}
static async getMySelf() {
const k = 'usermyself'
if (this.caches[k] != null)
return this.caches[k] as UserMySelf | null
this.caches[k] = await UserMySelf.getMySelf(getClient())
return this.caches[k] as UserMySelf | null
}
static async getUser(id: string) {
const k = 'user_' + id