Merge pull request #4821 from urbit/mp/landscape/me-highlight

landscape: highlight content mentioning our ship
This commit is contained in:
matildepark 2021-04-26 16:04:23 -04:00 committed by GitHub
commit 77219c6825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -264,6 +264,7 @@ class ChatMessage extends Component<ChatMessageProps> {
componentDidMount() {} componentDidMount() {}
render() { render() {
let { highlighted } = this.props;
const { const {
msg, msg,
previousMsg, previousMsg,
@ -279,12 +280,21 @@ class ChatMessage extends Component<ChatMessageProps> {
unreadMarkerRef, unreadMarkerRef,
history, history,
api, api,
highlighted,
showOurContact, showOurContact,
fontSize, fontSize,
hideHover hideHover
} = this.props; } = this.props;
const ourMention = msg?.contents?.some((e) => {
return e?.mention && e?.mention === window.ship;
});
if (!highlighted) {
if (ourMention) {
highlighted = true;
}
}
let onReply = this.props?.onReply ?? (() => {}); let onReply = this.props?.onReply ?? (() => {});
const transcluded = this.props?.transcluded ?? 0; const transcluded = this.props?.transcluded ?? 0;
let { renderSigil } = this.props; let { renderSigil } = this.props;

View File

@ -35,6 +35,7 @@ interface CommentItemProps {
} }
export function CommentItem(props: CommentItemProps): ReactElement { export function CommentItem(props: CommentItemProps): ReactElement {
let { highlighted } = props;
const { ship, name, api, comment, group } = props; const { ship, name, api, comment, group } = props;
const association = useMetadataState( const association = useMetadataState(
useCallback(s => s.associations.graph[`/ship/${ship}/${name}`], [ship,name]) useCallback(s => s.associations.graph[`/ship/${ship}/${name}`], [ship,name])
@ -47,6 +48,16 @@ export function CommentItem(props: CommentItemProps): ReactElement {
await api.graph.removeNodes(ship, name, [comment.post?.index]); await api.graph.removeNodes(ship, name, [comment.post?.index]);
}; };
const ourMention = post?.contents?.some((e) => {
return e?.mention && e?.mention === window.ship;
});
if (!highlighted) {
if (ourMention) {
highlighted = true;
}
}
const commentIndexArray = (comment.post?.index || '/').split('/'); const commentIndexArray = (comment.post?.index || '/').split('/');
const commentIndex = commentIndexArray[commentIndexArray.length - 1]; const commentIndex = commentIndexArray[commentIndexArray.length - 1];
@ -107,7 +118,7 @@ export function CommentItem(props: CommentItemProps): ReactElement {
borderRadius="1" borderRadius="1"
p="1" p="1"
mb="1" mb="1"
backgroundColor={props.highlighted ? 'washedBlue' : 'white'} backgroundColor={highlighted ? 'washedBlue' : 'white'}
transcluded={0} transcluded={0}
api={api} api={api}
post={post} post={post}