landscape: mentions respect calmengine

Fixes #4130.
This commit is contained in:
Matilde Park 2020-12-11 12:09:57 -05:00
parent 3662df0e73
commit 4530b59dd9
3 changed files with 27 additions and 10 deletions

View File

@ -261,6 +261,8 @@ export class MessageWithSigil extends PureComponent<MessageProps> {
measure={measure}
fontSize={fontSize}
group={group}
hideNicknames={hideNicknames}
hideAvatars={hideAvatars}
/>)}
</ContentBox>
</Box>
@ -276,16 +278,25 @@ const ContentBox = styled(Box)`
`;
export const MessageWithoutSigil = ({ timestamp, contacts, msg, remoteContentPolicy, measure, group }) => (
export const MessageWithoutSigil = ({ timestamp, contacts, msg, remoteContentPolicy, measure, group, hideNicknames, hideAvatars }) => (
<>
<Text flexShrink={0} mono gray display='inline-block' pt='2px' lineHeight='tall' className="child">{timestamp}</Text>
<ContentBox flexShrink={0} fontSize='14px' className="clamp-message" style={{ flexGrow: 1 }}>
{msg.contents.map(c => (<MessageContent contacts={contacts} content={c} group={group} remoteContentPolicy={remoteContentPolicy} measure={measure}/>))}
{msg.contents.map((c, i) => (
<MessageContent
key={i}
contacts={contacts}
content={c}
group={group}
remoteContentPolicy={remoteContentPolicy}
measure={measure}
hideNicknames={hideNicknames}
hideAvatars={hideAvatars}/>))}
</ContentBox>
</>
);
export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize, group }) => {
export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize, group, hideNicknames, hideAvatars }) => {
if ('code' in content) {
return <CodeContent content={content} />;
} else if ('url' in content) {
@ -314,7 +325,7 @@ export const MessageContent = ({ content, contacts, remoteContentPolicy, measure
} else if ('text' in content) {
return <TextContent fontSize={fontSize} content={content} />;
} else if ('mention' in content) {
return <Mention group={group} ship={content.mention} contacts={contacts} />
return <Mention group={group} ship={content.mention} contacts={contacts} hideNicknames={hideNicknames} hideAvatars={hideAvatars} />
} else {
return null;
}

View File

@ -82,6 +82,8 @@ export function CommentItem(props: CommentItemProps) {
group={group}
content={post?.contents}
remoteContentPolicy={remoteContentPolicy}
hideNicknames={props.hideNicknames}
hideAvatars={props.hideAvatars}
/>
</Box>
</Box>

View File

@ -17,9 +17,11 @@ interface MentionTextProps {
content: Content[];
group: Group;
remoteContentPolicy: LocalUpdateRemoteContentPolicy;
hideNicknames: boolean;
hideAvatars: boolean;
}
export function MentionText(props: MentionTextProps) {
const { content, contacts, group } = props;
const { content, contacts, group, hideNicknames } = props;
return (
<>
@ -36,7 +38,7 @@ export function MentionText(props: MentionTextProps) {
);
} else if ("mention" in c) {
return (
<Mention key={idx} contacts={contacts || {}} group={group} ship={c.mention} />
<Mention key={idx} contacts={contacts || {}} group={group} ship={c.mention} hideNicknames={hideNicknames} hideAvatars={hideAvatars} />
);
}
return null;
@ -49,10 +51,12 @@ export function Mention(props: {
ship: string;
contacts: Contacts;
group: Group;
hideNicknames: boolean;
hideAvatars: boolean;
}) {
const { contacts, ship } = props;
const { contacts, ship, hideNicknames, hideAvatars } = props;
const contact = contacts[ship];
const showNickname = !!contact?.nickname;
const showNickname = (Boolean(contact?.nickname) && !hideNicknames);
const name = showNickname ? contact?.nickname : cite(ship);
const [showOverlay, setShowOverlay] = useState(false);
const onDismiss = useCallback(() => {
@ -79,8 +83,8 @@ export function Mention(props: {
color={`#${uxToHex(contact?.color ?? '0x0')}`}
group={group}
onDismiss={onDismiss}
hideAvatars={false}
hideNicknames={false}
hideAvatars={hideAvatars || false}
hideNicknames={hideNicknames}
history={history}
/>
)}