landscape: highlight content with our mentions

This commit is contained in:
Matilde Park 2021-04-25 15:45:51 -04:00
parent bd81b4408e
commit 1d5cff849d
2 changed files with 23 additions and 2 deletions

View File

@ -264,6 +264,7 @@ class ChatMessage extends Component<ChatMessageProps> {
componentDidMount() {}
render() {
let { highlighted } = this.props;
const {
msg,
previousMsg,
@ -279,12 +280,21 @@ class ChatMessage extends Component<ChatMessageProps> {
unreadMarkerRef,
history,
api,
highlighted,
showOurContact,
fontSize,
hideHover
} = 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 ?? (() => {});
const transcluded = this.props?.transcluded ?? 0;
let { renderSigil } = this.props;

View File

@ -35,6 +35,7 @@ interface CommentItemProps {
}
export function CommentItem(props: CommentItemProps): ReactElement {
let { highlighted } = props;
const { ship, name, api, comment, group } = props;
const association = useMetadataState(
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]);
};
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 commentIndex = commentIndexArray[commentIndexArray.length - 1];
@ -106,7 +117,7 @@ export function CommentItem(props: CommentItemProps): ReactElement {
borderRadius="1"
p="1"
mb="1"
backgroundColor={props.highlighted ? 'washedBlue' : 'white'}
backgroundColor={highlighted ? 'washedBlue' : 'white'}
transcluded={0}
api={api}
post={post}