mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 21:12:56 +03:00
Merge pull request #4132 from urbit/mp/landscape/chat-fix
chat: fixes two regressions
This commit is contained in:
commit
745b04d39c
@ -144,12 +144,12 @@ export default class ChatMessage extends Component<ChatMessageProps> {
|
|||||||
style={style}
|
style={style}
|
||||||
mb={1}
|
mb={1}
|
||||||
>
|
>
|
||||||
{dayBreak && !isLastRead ? <DayBreak when={msg.when} /> : null}
|
{dayBreak && !isLastRead ? <DayBreak when={msg['time-sent']} /> : null}
|
||||||
{renderSigil
|
{renderSigil
|
||||||
? <MessageWithSigil {...messageProps} />
|
? <MessageWithSigil {...messageProps} />
|
||||||
: <MessageWithoutSigil {...messageProps} />}
|
: <MessageWithoutSigil {...messageProps} />}
|
||||||
<Box flexShrink={0} fontSize={0} position='relative' width='100%' overflow='visible' style={unreadContainerStyle}>{isLastRead
|
<Box flexShrink={0} fontSize={0} position='relative' width='100%' overflow='visible' style={unreadContainerStyle}>{isLastRead
|
||||||
? <UnreadMarker dayBreak={dayBreak} when={msg.when} ref={unreadMarkerRef} />
|
? <UnreadMarker dayBreak={dayBreak} when={msg['time-sent']} ref={unreadMarkerRef} />
|
||||||
: null}</Box>
|
: null}</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@ -261,6 +261,8 @@ export class MessageWithSigil extends PureComponent<MessageProps> {
|
|||||||
measure={measure}
|
measure={measure}
|
||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
group={group}
|
group={group}
|
||||||
|
hideNicknames={hideNicknames}
|
||||||
|
hideAvatars={hideAvatars}
|
||||||
/>)}
|
/>)}
|
||||||
</ContentBox>
|
</ContentBox>
|
||||||
</Box>
|
</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>
|
<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 }}>
|
<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>
|
</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) {
|
if ('code' in content) {
|
||||||
return <CodeContent content={content} />;
|
return <CodeContent content={content} />;
|
||||||
} else if ('url' in content) {
|
} else if ('url' in content) {
|
||||||
@ -314,7 +325,7 @@ export const MessageContent = ({ content, contacts, remoteContentPolicy, measure
|
|||||||
} else if ('text' in content) {
|
} else if ('text' in content) {
|
||||||
return <TextContent fontSize={fontSize} content={content} />;
|
return <TextContent fontSize={fontSize} content={content} />;
|
||||||
} else if ('mention' in content) {
|
} else if ('mention' in content) {
|
||||||
return <Mention group={group} ship={content.mention} contacts={contacts} />
|
return <Mention group={group} ship={content.mention} contact={contacts?.[content.mention]} hideNicknames={hideNicknames} hideAvatars={hideAvatars} />
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ export function CommentItem(props: CommentItemProps) {
|
|||||||
group={group}
|
group={group}
|
||||||
content={post?.contents}
|
content={post?.contents}
|
||||||
remoteContentPolicy={remoteContentPolicy}
|
remoteContentPolicy={remoteContentPolicy}
|
||||||
|
hideNicknames={props.hideNicknames}
|
||||||
|
hideAvatars={props.hideAvatars}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -2,6 +2,7 @@ import React, { useState, useCallback } from "react";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { Text, Box } from "@tlon/indigo-react";
|
import { Text, Box } from "@tlon/indigo-react";
|
||||||
import {
|
import {
|
||||||
|
Contact,
|
||||||
Contacts,
|
Contacts,
|
||||||
Content,
|
Content,
|
||||||
LocalUpdateRemoteContentPolicy,
|
LocalUpdateRemoteContentPolicy,
|
||||||
@ -13,13 +14,16 @@ import { ProfileOverlay } from "./ProfileOverlay";
|
|||||||
import {useHistory} from "react-router-dom";
|
import {useHistory} from "react-router-dom";
|
||||||
|
|
||||||
interface MentionTextProps {
|
interface MentionTextProps {
|
||||||
contacts: Contacts;
|
contact?: Contact;
|
||||||
|
contacts?: Contacts;
|
||||||
content: Content[];
|
content: Content[];
|
||||||
group: Group;
|
group: Group;
|
||||||
remoteContentPolicy: LocalUpdateRemoteContentPolicy;
|
remoteContentPolicy: LocalUpdateRemoteContentPolicy;
|
||||||
|
hideNicknames: boolean;
|
||||||
|
hideAvatars: boolean;
|
||||||
}
|
}
|
||||||
export function MentionText(props: MentionTextProps) {
|
export function MentionText(props: MentionTextProps) {
|
||||||
const { content, contacts, group } = props;
|
const { content, contacts, contact, group, hideNicknames, hideAvatars } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -36,7 +40,7 @@ export function MentionText(props: MentionTextProps) {
|
|||||||
);
|
);
|
||||||
} else if ("mention" in c) {
|
} else if ("mention" in c) {
|
||||||
return (
|
return (
|
||||||
<Mention key={idx} contacts={contacts || {}} group={group} ship={c.mention} />
|
<Mention key={idx} contacts={contacts || {}} contact={contact || {}} group={group} ship={c.mention} hideNicknames={hideNicknames} hideAvatars={hideAvatars} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -47,12 +51,18 @@ export function MentionText(props: MentionTextProps) {
|
|||||||
|
|
||||||
export function Mention(props: {
|
export function Mention(props: {
|
||||||
ship: string;
|
ship: string;
|
||||||
contacts: Contacts;
|
contact: Contact;
|
||||||
|
contacts?: Contacts;
|
||||||
group: Group;
|
group: Group;
|
||||||
|
hideNicknames: boolean;
|
||||||
|
hideAvatars: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { contacts, ship } = props;
|
const { contacts, ship, hideNicknames, hideAvatars } = props;
|
||||||
const contact = contacts[ship];
|
let { contact } = props;
|
||||||
const showNickname = !!contact?.nickname;
|
|
||||||
|
contact = (contact?.nickname) ? contact : contacts?.[ship];
|
||||||
|
|
||||||
|
const showNickname = (Boolean(contact?.nickname) && !hideNicknames);
|
||||||
const name = showNickname ? contact?.nickname : cite(ship);
|
const name = showNickname ? contact?.nickname : cite(ship);
|
||||||
const [showOverlay, setShowOverlay] = useState(false);
|
const [showOverlay, setShowOverlay] = useState(false);
|
||||||
const onDismiss = useCallback(() => {
|
const onDismiss = useCallback(() => {
|
||||||
@ -79,8 +89,8 @@ export function Mention(props: {
|
|||||||
color={`#${uxToHex(contact?.color ?? '0x0')}`}
|
color={`#${uxToHex(contact?.color ?? '0x0')}`}
|
||||||
group={group}
|
group={group}
|
||||||
onDismiss={onDismiss}
|
onDismiss={onDismiss}
|
||||||
hideAvatars={false}
|
hideAvatars={hideAvatars || false}
|
||||||
hideNicknames={false}
|
hideNicknames={hideNicknames}
|
||||||
history={history}
|
history={history}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user