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.
16 lines
413 B
TypeScript
16 lines
413 B
TypeScript
import { getCachedUserInfo } from '../../cache/cache';
|
|
import { useAsync } from '../useAsync';
|
|
|
|
/**
|
|
* 用户名列表
|
|
*/
|
|
export function useUsernames(userIds: string[]): string[] {
|
|
const { value: names = [] } = useAsync(async () => {
|
|
const users = await Promise.all(userIds.map((id) => getCachedUserInfo(id)));
|
|
|
|
return users.map((user) => user.nickname);
|
|
}, [userIds.join(',')]);
|
|
|
|
return names;
|
|
}
|