mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 08:34:25 +03:00
publish: mentions support
This commit is contained in:
parent
7dce8a6d6b
commit
c221b211cb
@ -6,14 +6,15 @@ import GlobalApi from "~/logic/api/global";
|
||||
import { Box, Row } from "@tlon/indigo-react";
|
||||
import styled from "styled-components";
|
||||
import { Author } from "./Author";
|
||||
import {GraphNode, TextContent} from "~/types/graph-update";
|
||||
import tokenizeMessage from '~/logic/lib/tokenizeMessage';
|
||||
import RichText from '~/views/components/RichText';
|
||||
import {LocalUpdateRemoteContentPolicy} from "~/types";
|
||||
import { GraphNode, TextContent } from "~/types/graph-update";
|
||||
import tokenizeMessage from "~/logic/lib/tokenizeMessage";
|
||||
import RichText from "~/views/components/RichText";
|
||||
import { LocalUpdateRemoteContentPolicy } from "~/types";
|
||||
import { MentionText } from "~/views/components/MentionText";
|
||||
|
||||
const ClickBox = styled(Box)`
|
||||
cursor: pointer;
|
||||
padding-left: ${p => p.theme.space[2]}px;
|
||||
padding-left: ${(p) => p.theme.space[2]}px;
|
||||
`;
|
||||
|
||||
interface CommentItemProps {
|
||||
@ -31,9 +32,7 @@ interface CommentItemProps {
|
||||
export function CommentItem(props: CommentItemProps) {
|
||||
const { ship, contacts, book, api, remoteContentPolicy } = props;
|
||||
const commentData = props.comment?.post;
|
||||
const comment = commentData.contents[0] as TextContent;
|
||||
|
||||
const content = tokenizeMessage(comment.text).flat().join(' ');
|
||||
const comment = commentData.contents;
|
||||
|
||||
const disabled = props.pending || window.ship !== commentData.author;
|
||||
|
||||
@ -62,7 +61,11 @@ export function CommentItem(props: CommentItemProps) {
|
||||
</Author>
|
||||
</Row>
|
||||
<Box mb={2}>
|
||||
<RichText className="f9 white-d" remoteContentPolicy={remoteContentPolicy}>{content}</RichText>
|
||||
<MentionText
|
||||
contacts={contacts}
|
||||
content={comment}
|
||||
remoteContentPolicy={remoteContentPolicy}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
@ -11,6 +11,7 @@ import { FormikHelpers } from "formik";
|
||||
import {GraphNode, Graph} from "~/types/graph-update";
|
||||
import {createPost} from "~/logic/api/graph";
|
||||
import { LocalUpdateRemoteContentPolicy } from "~/types";
|
||||
import {scanForMentions} from "~/logic/lib/graph";
|
||||
|
||||
interface CommentsProps {
|
||||
comments: GraphNode;
|
||||
@ -32,7 +33,8 @@ export function Comments(props: CommentsProps) {
|
||||
actions: FormikHelpers<{ comment: string }>
|
||||
) => {
|
||||
try {
|
||||
const post = createPost([{ text: comment }], comments?.post?.index);
|
||||
const content = scanForMentions(comment)
|
||||
const post = createPost(content, comments?.post?.index);
|
||||
await api.graph.addPost(ship, book, post)
|
||||
actions.resetForm();
|
||||
actions.setStatus({ success: null });
|
||||
@ -48,7 +50,7 @@ export function Comments(props: CommentsProps) {
|
||||
{Array.from(comments.children).reverse().map(([idx, comment]) => (
|
||||
<CommentItem
|
||||
comment={comment}
|
||||
key={idx}
|
||||
key={idx.toString()}
|
||||
contacts={props.contacts}
|
||||
api={api}
|
||||
book={book}
|
||||
|
Loading…
Reference in New Issue
Block a user