mirror of https://github.com/msgbyte/tailchat
feat: 增加reaction的用户昵称渲染
parent
f339302203
commit
f9578ae07b
@ -0,0 +1,15 @@
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue