diff --git a/lib/shared/user-utils.js b/lib/shared/user-utils.js index 2fb8d7f50..fd092fa39 100644 --- a/lib/shared/user-utils.js +++ b/lib/shared/user-utils.js @@ -1,58 +1,61 @@ // @flow import bots from '../facts/bots'; import staff from '../facts/staff'; +import { useENSNames } from '../hooks/ens-cache'; import type { ServerThreadInfo, RawThreadInfo, ThreadInfo, } from '../types/thread-types'; import type { UserInfo } from '../types/user-types'; import { useSelector } from '../utils/redux-utils'; import { memberHasAdminPowers } from './thread-utils'; function stringForUser(user: { +username?: ?string, +isViewer?: ?boolean, ... }): string { if (user.isViewer) { return 'you'; } return stringForUserExplicit(user); } function stringForUserExplicit(user: { +username: ?string, ... }): string { if (user.username) { return user.username; } else { return 'anonymous'; } } function isStaff(userID: string): boolean { if (staff.includes(userID)) { return true; } for (const key in bots) { const bot = bots[key]; if (userID === bot.userID) { return true; } } return false; } function useKeyserverAdmin( community: ThreadInfo | RawThreadInfo | ServerThreadInfo, ): ?UserInfo { const userInfos = useSelector(state => state.userStore.userInfos); // This hack only works as long as there is only one admin // Linear task to revert this: // https://linear.app/comm/issue/ENG-1707/revert-fix-getting-the-keyserver-admin-info const admin = community.members.find(memberHasAdminPowers); - return admin ? userInfos[admin.id] : undefined; + const adminUserInfo = admin ? userInfos[admin.id] : undefined; + const [adminUserInfoWithENSName] = useENSNames([adminUserInfo]); + return adminUserInfoWithENSName; } export { stringForUser, stringForUserExplicit, isStaff, useKeyserverAdmin };