mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
comment locking initial
This commit is contained in:
parent
6eafc227da
commit
59d544c5f4
10 changed files with 139 additions and 44 deletions
|
@ -5,12 +5,16 @@ import { Filler } from '~/components/containers/Filler';
|
|||
import * as styles from './styles.scss';
|
||||
import { ICommentGroup, IComment } from '~/redux/types';
|
||||
import { groupCommentsByUser } from '~/utils/fn';
|
||||
import { IUser } from '~/redux/auth/types';
|
||||
import { canEditComment } from '~/utils/node';
|
||||
|
||||
interface IProps {
|
||||
comments?: IComment[];
|
||||
user: IUser;
|
||||
onDelete: (id: IComment['id'], is_deteted: boolean) => void;
|
||||
}
|
||||
|
||||
const NodeComments: FC<IProps> = memo(({ comments }) => {
|
||||
const NodeComments: FC<IProps> = memo(({ comments, user, onDelete }) => {
|
||||
const groupped: ICommentGroup[] = useMemo(() => comments.reduce(groupCommentsByUser, []), [
|
||||
comments,
|
||||
]);
|
||||
|
@ -18,7 +22,12 @@ const NodeComments: FC<IProps> = memo(({ comments }) => {
|
|||
return (
|
||||
<div className={styles.wrap}>
|
||||
{groupped.map(group => (
|
||||
<Comment key={group.ids.join()} comment_group={group} />
|
||||
<Comment
|
||||
key={group.ids.join()}
|
||||
comment_group={group}
|
||||
can_edit={canEditComment(group, user)}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
))}
|
||||
|
||||
<Filler />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue