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

View File

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

View File

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