mirror of https://github.com/msgbyte/tailchat
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.
20 lines
465 B
TypeScript
20 lines
465 B
TypeScript
2 years ago
|
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;
|
||
|
}
|