diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index 50a8f9c5..30878919 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -44,7 +44,9 @@ export const Comment = (props: Props) => { const { showSnackbar } = useSnackbar() const canEdit = createMemo( - () => props.comment.created_by?.slug === author()?.slug || session()?.user?.roles.includes('editor'), + () => + Boolean(author()?.id) && + (props.comment?.created_by?.id === author().id || session()?.user?.roles.includes('editor')), ) const comment = createMemo(() => props.comment) const body = createMemo(() => (comment().body || '').trim()) diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index bcb5870e..4c4d1775 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -78,11 +78,13 @@ export const FullArticle = (props: Props) => { const { author, session, isAuthenticated, requireAuthentication } = useSession() const formattedDate = createMemo(() => formatDate(new Date(props.article.published_at * 1000))) + const canEdit = createMemo( () => - props.article.authors?.some((a) => Boolean(a) && a?.slug === author()?.slug) || - props.article?.created_by.slug === author()?.slug || - session()?.user?.roles.includes('editor'), + Boolean(author()?.id) && + (props.article?.authors?.some((a) => Boolean(a) && a?.id === author().id) || + props.article?.created_by?.id === author().id || + session()?.user?.roles.includes('editor')), ) const mainTopic = createMemo(() => { diff --git a/src/components/Feed/ArticleCard/ArticleCard.tsx b/src/components/Feed/ArticleCard/ArticleCard.tsx index 66905e0c..4d661dc8 100644 --- a/src/components/Feed/ArticleCard/ArticleCard.tsx +++ b/src/components/Feed/ArticleCard/ArticleCard.tsx @@ -122,9 +122,10 @@ export const ArticleCard = (props: ArticleCardProps) => { const canEdit = createMemo( () => - props.article.authors?.some((a) => a && a?.slug === author()?.slug) || - props.article.created_by?.id === author()?.id || - session()?.user?.roles.includes('editor'), + Boolean(author()?.id) && + (props.article?.authors?.some((a) => Boolean(a) && a?.id === author().id) || + props.article?.created_by?.id === author().id || + session()?.user?.roles.includes('editor')), ) const scrollToComments = (event) => {