links: mention support

This commit is contained in:
Liam Fitzgerald 2020-11-03 16:13:00 +10:00
parent 94f787d120
commit 7dce8a6d6b
3 changed files with 12 additions and 8 deletions

View File

@ -4,9 +4,10 @@ import { cite } from '~/logic/lib/util';
import moment from 'moment';
import { Box, Text, Row } from '@tlon/indigo-react';
import RichText from '~/views/components/RichText';
import { MentionText } from "~/views/components/MentionText";
export const CommentItem = (props) => {
const content = props.post.contents[0].text;
const content = props.post.contents;
const timeSent =
moment.unix(props.post['time-sent'] / 1000).format('hh:mm a');
@ -33,10 +34,12 @@ export const CommentItem = (props) => {
</Row>
</Row>
<Row>
<Text display="block" py={3} fontSize={1}>
<RichText remoteContentPolicy={props.remoteContentPolicy}>
{content}
</RichText>
<Text py={3} fontSize={1}>
<MentionText
remoteContentPolicy={props.remoteContentPolicy}
contacts={props.contacts}
content={content}
/>
</Text>
</Row>
</Box>

View File

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { Spinner } from '~/views/components/Spinner';
import { createPost } from '~/logic/api/graph';
import { deSig } from "~/logic/lib/util";
import { scanForMentions } from "~/logic/lib/graph";
export class CommentSubmit extends Component {
@ -17,9 +18,8 @@ export class CommentSubmit extends Component {
onClickPost() {
const parentIndex = this.props.parentIndex || '';
let post = createPost([
{ text: this.state.comment },
], parentIndex);
const content = scanForMentions(this.state.comment);
let post = createPost(content, parentIndex);
this.setState({ disabled: true }, () => {
this.props.api.graph.addPost(

View File

@ -23,6 +23,7 @@ export const Comments = (props) => {
return (
<CommentItem
key={comment.post.index}
contacts={contacts}
post={comment.post}
nickname={nickname}
hasNickname={Boolean(nickname)}