mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed new comments highlight for same user
This commit is contained in:
parent
e96ab08210
commit
73c30b6d25
3 changed files with 14 additions and 17 deletions
|
@ -11,21 +11,21 @@ import { NEW_COMMENT_CLASSNAME } from '~/constants/comment';
|
|||
type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||
is_empty?: boolean;
|
||||
is_loading?: boolean;
|
||||
comment_group: ICommentGroup;
|
||||
is_same?: boolean;
|
||||
can_edit?: boolean;
|
||||
group: ICommentGroup;
|
||||
isSame?: boolean;
|
||||
canEdit?: boolean;
|
||||
onDelete: (id: IComment['id'], isLocked: boolean) => void;
|
||||
modalShowPhotoswipe: typeof MODAL_ACTIONS.modalShowPhotoswipe;
|
||||
};
|
||||
|
||||
const Comment: FC<IProps> = memo(
|
||||
({
|
||||
comment_group,
|
||||
group,
|
||||
is_empty,
|
||||
is_same,
|
||||
isSame,
|
||||
is_loading,
|
||||
className,
|
||||
can_edit,
|
||||
canEdit,
|
||||
onDelete,
|
||||
modalShowPhotoswipe,
|
||||
...props
|
||||
|
@ -33,17 +33,16 @@ const Comment: FC<IProps> = memo(
|
|||
return (
|
||||
<CommentWrapper
|
||||
className={classNames(className, {
|
||||
[NEW_COMMENT_CLASSNAME]: comment_group.hasNew,
|
||||
[NEW_COMMENT_CLASSNAME]: group.hasNew,
|
||||
})}
|
||||
isEmpty={is_empty}
|
||||
isLoading={is_loading}
|
||||
user={comment_group.user}
|
||||
isSame={is_same}
|
||||
isNew={comment_group.hasNew}
|
||||
user={group.user}
|
||||
isNew={group.hasNew && !isSame}
|
||||
{...props}
|
||||
>
|
||||
<div className={styles.wrap}>
|
||||
{comment_group.comments.map(comment => {
|
||||
{group.comments.map(comment => {
|
||||
if (comment.deleted_at) {
|
||||
return <CommendDeleted id={comment.id} onDelete={onDelete} key={comment.id} />;
|
||||
}
|
||||
|
@ -52,7 +51,7 @@ const Comment: FC<IProps> = memo(
|
|||
<CommentContent
|
||||
comment={comment}
|
||||
key={comment.id}
|
||||
can_edit={!!can_edit}
|
||||
can_edit={!!canEdit}
|
||||
onDelete={onDelete}
|
||||
modalShowPhotoswipe={modalShowPhotoswipe}
|
||||
/>
|
||||
|
|
|
@ -11,7 +11,6 @@ type IProps = DivProps & {
|
|||
user: IUser;
|
||||
isEmpty?: boolean;
|
||||
isLoading?: boolean;
|
||||
isSame?: boolean;
|
||||
isForm?: boolean;
|
||||
isNew?: boolean;
|
||||
};
|
||||
|
@ -21,7 +20,6 @@ const CommentWrapper: FC<IProps> = ({
|
|||
className,
|
||||
isEmpty,
|
||||
isLoading,
|
||||
isSame,
|
||||
isForm,
|
||||
children,
|
||||
isNew,
|
||||
|
@ -31,7 +29,6 @@ const CommentWrapper: FC<IProps> = ({
|
|||
className={classNames(styles.wrap, className, {
|
||||
[styles.is_empty]: isEmpty,
|
||||
[styles.is_loading]: isLoading,
|
||||
[styles.is_same]: isSame,
|
||||
[styles.is_new]: isNew,
|
||||
})}
|
||||
{...props}
|
||||
|
|
|
@ -58,10 +58,11 @@ const NodeComments: FC<IProps> = memo(
|
|||
{groupped.map(group => (
|
||||
<Comment
|
||||
key={group.ids.join()}
|
||||
comment_group={group}
|
||||
can_edit={canEditComment(group, user)}
|
||||
group={group}
|
||||
canEdit={canEditComment(group, user)}
|
||||
onDelete={onDelete}
|
||||
modalShowPhotoswipe={onShowPhotoswipe}
|
||||
isSame={group.user.id === user.id}
|
||||
/>
|
||||
))}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue