diff --git a/web/chat/chat-thread-ancestors.react.js b/web/chat/chat-thread-ancestors.react.js index 5cc032031..79daeab90 100644 --- a/web/chat/chat-thread-ancestors.react.js +++ b/web/chat/chat-thread-ancestors.react.js @@ -1,124 +1,128 @@ // @flow import classNames from 'classnames'; import * as React from 'react'; import { useAncestorThreads } from 'lib/shared/ancestor-threads'; import { colorIsDark } from 'lib/shared/thread-utils'; import { useKeyserverAdmin } from 'lib/shared/user-utils'; import type { ThreadInfo } from 'lib/types/thread-types'; +import { useResolvedThreadInfo } from 'lib/utils/entity-helpers'; import CommIcon from '../CommIcon.react'; import SWMansionIcon from '../SWMansionIcon.react'; import css from './chat-thread-ancestors.css'; const SHOW_SEE_FULL_STRUCTURE = false; type ThreadAncestorsProps = { +threadInfo: ThreadInfo, }; function ThreadAncestors(props: ThreadAncestorsProps): React.Node { const { threadInfo } = props; const { color: threadColor } = threadInfo; const darkColor = colorIsDark(threadColor); const threadColorStyle = React.useMemo( () => ({ backgroundColor: `#${threadColor}`, color: darkColor ? 'var(--thread-ancestor-color-light)' : 'var(--thread-ancestor-color-dark)', }), [darkColor, threadColor], ); const fullStructureButtonColorStyle = React.useMemo( () => ({ color: `#${threadColor}` }), [threadColor], ); const ancestorThreads = useAncestorThreads(threadInfo); const community = ancestorThreads[0] ?? threadInfo; const keyserverAdmin = useKeyserverAdmin(community); const keyserverOwnerUsername = keyserverAdmin?.username; + const resolvedCommunity = useResolvedThreadInfo(community); + const keyserverInfo = React.useMemo( () => (
{keyserverOwnerUsername}
- {community.uiName} + {resolvedCommunity.uiName}
), - [community.uiName, keyserverOwnerUsername, threadColorStyle], + [resolvedCommunity.uiName, keyserverOwnerUsername, threadColorStyle], ); const middlePath = React.useMemo(() => { if (ancestorThreads.length < 2) { return null; } return ( <>
); }, [ancestorThreads.length, threadColorStyle]); const threadHasNoAncestors = community === threadInfo; + const { uiName } = useResolvedThreadInfo(threadInfo); const currentThread = React.useMemo(() => { if (threadHasNoAncestors) { return null; } return ( <>
- {threadInfo.uiName} + {uiName}
); - }, [threadHasNoAncestors, threadColorStyle, threadInfo.uiName]); + }, [threadHasNoAncestors, threadColorStyle, uiName]); let seeFullStructure = null; if (SHOW_SEE_FULL_STRUCTURE) { seeFullStructure = ( ); } return ( <>
{keyserverInfo} {middlePath} {currentThread}
{seeFullStructure} ); } export default ThreadAncestors;