From 98264cfce7a9f713a663914af1daaef5d2cad274 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 16 Feb 2024 13:21:25 +0300 Subject: [PATCH] canEdit-fix --- src/components/Article/Comment/Comment.tsx | 12 ++++++------ src/components/Article/FullArticle.tsx | 9 +++++++-- src/components/Feed/ArticleCard/ArticleCard.tsx | 11 +++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index d6af579f..50a8f9c5 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -38,12 +38,14 @@ export const Comment = (props: Props) => { const [loading, setLoading] = createSignal(false) const [editMode, setEditMode] = createSignal(false) const [clearEditor, setClearEditor] = createSignal(false) - const { author } = useSession() + const { author, session } = useSession() const { createReaction, deleteReaction, updateReaction } = useReactions() const { showConfirm } = useConfirm() const { showSnackbar } = useSnackbar() - const isCommentAuthor = createMemo(() => props.comment.created_by?.slug === author()?.slug) + const canEdit = createMemo( + () => props.comment.created_by?.slug === author()?.slug || session()?.user?.roles.includes('editor'), + ) const comment = createMemo(() => props.comment) const body = createMemo(() => (comment().body || '').trim()) @@ -108,9 +110,7 @@ export const Comment = (props: Props) => { return (
  • props.lastSeen, - })} + class={clsx(styles.comment, props.class, { [styles.isNew]: comment()?.created_at > props.lastSeen })} >
    @@ -189,7 +189,7 @@ export const Comment = (props: Props) => { {loading() ? t('Loading') : t('Reply')} - +