mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +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> & {
|
type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||||
is_empty?: boolean;
|
is_empty?: boolean;
|
||||||
is_loading?: boolean;
|
is_loading?: boolean;
|
||||||
comment_group: ICommentGroup;
|
group: ICommentGroup;
|
||||||
is_same?: boolean;
|
isSame?: boolean;
|
||||||
can_edit?: boolean;
|
canEdit?: boolean;
|
||||||
onDelete: (id: IComment['id'], isLocked: boolean) => void;
|
onDelete: (id: IComment['id'], isLocked: boolean) => void;
|
||||||
modalShowPhotoswipe: typeof MODAL_ACTIONS.modalShowPhotoswipe;
|
modalShowPhotoswipe: typeof MODAL_ACTIONS.modalShowPhotoswipe;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Comment: FC<IProps> = memo(
|
const Comment: FC<IProps> = memo(
|
||||||
({
|
({
|
||||||
comment_group,
|
group,
|
||||||
is_empty,
|
is_empty,
|
||||||
is_same,
|
isSame,
|
||||||
is_loading,
|
is_loading,
|
||||||
className,
|
className,
|
||||||
can_edit,
|
canEdit,
|
||||||
onDelete,
|
onDelete,
|
||||||
modalShowPhotoswipe,
|
modalShowPhotoswipe,
|
||||||
...props
|
...props
|
||||||
|
@ -33,17 +33,16 @@ const Comment: FC<IProps> = memo(
|
||||||
return (
|
return (
|
||||||
<CommentWrapper
|
<CommentWrapper
|
||||||
className={classNames(className, {
|
className={classNames(className, {
|
||||||
[NEW_COMMENT_CLASSNAME]: comment_group.hasNew,
|
[NEW_COMMENT_CLASSNAME]: group.hasNew,
|
||||||
})}
|
})}
|
||||||
isEmpty={is_empty}
|
isEmpty={is_empty}
|
||||||
isLoading={is_loading}
|
isLoading={is_loading}
|
||||||
user={comment_group.user}
|
user={group.user}
|
||||||
isSame={is_same}
|
isNew={group.hasNew && !isSame}
|
||||||
isNew={comment_group.hasNew}
|
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
{comment_group.comments.map(comment => {
|
{group.comments.map(comment => {
|
||||||
if (comment.deleted_at) {
|
if (comment.deleted_at) {
|
||||||
return <CommendDeleted id={comment.id} onDelete={onDelete} key={comment.id} />;
|
return <CommendDeleted id={comment.id} onDelete={onDelete} key={comment.id} />;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +51,7 @@ const Comment: FC<IProps> = memo(
|
||||||
<CommentContent
|
<CommentContent
|
||||||
comment={comment}
|
comment={comment}
|
||||||
key={comment.id}
|
key={comment.id}
|
||||||
can_edit={!!can_edit}
|
can_edit={!!canEdit}
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
modalShowPhotoswipe={modalShowPhotoswipe}
|
modalShowPhotoswipe={modalShowPhotoswipe}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -11,7 +11,6 @@ type IProps = DivProps & {
|
||||||
user: IUser;
|
user: IUser;
|
||||||
isEmpty?: boolean;
|
isEmpty?: boolean;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
isSame?: boolean;
|
|
||||||
isForm?: boolean;
|
isForm?: boolean;
|
||||||
isNew?: boolean;
|
isNew?: boolean;
|
||||||
};
|
};
|
||||||
|
@ -21,7 +20,6 @@ const CommentWrapper: FC<IProps> = ({
|
||||||
className,
|
className,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
isLoading,
|
isLoading,
|
||||||
isSame,
|
|
||||||
isForm,
|
isForm,
|
||||||
children,
|
children,
|
||||||
isNew,
|
isNew,
|
||||||
|
@ -31,7 +29,6 @@ const CommentWrapper: FC<IProps> = ({
|
||||||
className={classNames(styles.wrap, className, {
|
className={classNames(styles.wrap, className, {
|
||||||
[styles.is_empty]: isEmpty,
|
[styles.is_empty]: isEmpty,
|
||||||
[styles.is_loading]: isLoading,
|
[styles.is_loading]: isLoading,
|
||||||
[styles.is_same]: isSame,
|
|
||||||
[styles.is_new]: isNew,
|
[styles.is_new]: isNew,
|
||||||
})}
|
})}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
@ -58,10 +58,11 @@ const NodeComments: FC<IProps> = memo(
|
||||||
{groupped.map(group => (
|
{groupped.map(group => (
|
||||||
<Comment
|
<Comment
|
||||||
key={group.ids.join()}
|
key={group.ids.join()}
|
||||||
comment_group={group}
|
group={group}
|
||||||
can_edit={canEditComment(group, user)}
|
canEdit={canEditComment(group, user)}
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
modalShowPhotoswipe={onShowPhotoswipe}
|
modalShowPhotoswipe={onShowPhotoswipe}
|
||||||
|
isSame={group.user.id === user.id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue