You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/client/shared/hooks/model/useUserInfo.ts

20 lines
465 B
TypeScript

import { getCachedUserInfo } from '../../cache/cache';
import type { UserBaseInfo } from '../../model/user';
import { useAsync } from '../useAsync';
/**
* 用户信息
*/
export function useCachedUserInfo(
userId: string,
refetch = false
): UserBaseInfo | Record<string, never> {
const { value: userInfo = {} } = useAsync(async () => {
const users = getCachedUserInfo(userId, refetch);
return users;
}, [userId, refetch]);
return userInfo;
}