feat(reply): implement instant edits

This commit is contained in:
plebeius.eth
2024-01-05 11:30:58 +01:00
parent c1dfcc1753
commit 38cb7d9b62
2 changed files with 8 additions and 3 deletions

View File

@@ -105,9 +105,9 @@ const Post = ({ post = {}, index }: PostProps) => {
const isInPostView = isPostView(location.pathname, params);
const isInPendingView = isPendingView(location.pathname, params);
const isInSubplebbitView = isSubplebbitView(location.pathname, params);
const isInPostView = isInPostView || isInPendingView;
const isInPostPage = isInPostView || isInPendingView;
const [isExpanded, setIsExpanded] = useState(isInPostView);
const [isExpanded, setIsExpanded] = useState(isInPostPage);
const toggleExpanded = () => setIsExpanded(!isExpanded);
const [upvoted, upvote] = useUpvote(post);

View File

@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from 'react';
import { Comment, useAccountComment, useAuthorAddress, useBlock, useComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { Comment, useAccountComment, useAuthorAddress, useBlock, useComment, useEditedComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils';
import { Link, useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
@@ -187,6 +187,11 @@ interface ReplyProps {
}
const Reply = ({ depth = 0, isSingle, isNotification = false, reply = {} }: ReplyProps) => {
// handle pending mod or author edit
const { editedComment: editedPost } = useEditedComment({ comment: reply });
if (editedPost) {
reply = editedPost;
}
const {
author,
cid,