can-edit-fix-2
This commit is contained in:
parent
98264cfce7
commit
19bba97d73
|
@ -44,7 +44,9 @@ export const Comment = (props: Props) => {
|
||||||
const { showSnackbar } = useSnackbar()
|
const { showSnackbar } = useSnackbar()
|
||||||
|
|
||||||
const canEdit = createMemo(
|
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 comment = createMemo(() => props.comment)
|
||||||
const body = createMemo(() => (comment().body || '').trim())
|
const body = createMemo(() => (comment().body || '').trim())
|
||||||
|
|
|
@ -78,11 +78,13 @@ export const FullArticle = (props: Props) => {
|
||||||
const { author, session, isAuthenticated, requireAuthentication } = useSession()
|
const { author, session, isAuthenticated, requireAuthentication } = useSession()
|
||||||
|
|
||||||
const formattedDate = createMemo(() => formatDate(new Date(props.article.published_at * 1000)))
|
const formattedDate = createMemo(() => formatDate(new Date(props.article.published_at * 1000)))
|
||||||
|
|
||||||
const canEdit = createMemo(
|
const canEdit = createMemo(
|
||||||
() =>
|
() =>
|
||||||
props.article.authors?.some((a) => Boolean(a) && a?.slug === author()?.slug) ||
|
Boolean(author()?.id) &&
|
||||||
props.article?.created_by.slug === author()?.slug ||
|
(props.article?.authors?.some((a) => Boolean(a) && a?.id === author().id) ||
|
||||||
session()?.user?.roles.includes('editor'),
|
props.article?.created_by?.id === author().id ||
|
||||||
|
session()?.user?.roles.includes('editor')),
|
||||||
)
|
)
|
||||||
|
|
||||||
const mainTopic = createMemo(() => {
|
const mainTopic = createMemo(() => {
|
||||||
|
|
|
@ -122,9 +122,10 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
|
|
||||||
const canEdit = createMemo(
|
const canEdit = createMemo(
|
||||||
() =>
|
() =>
|
||||||
props.article.authors?.some((a) => a && a?.slug === author()?.slug) ||
|
Boolean(author()?.id) &&
|
||||||
props.article.created_by?.id === author()?.id ||
|
(props.article?.authors?.some((a) => Boolean(a) && a?.id === author().id) ||
|
||||||
session()?.user?.roles.includes('editor'),
|
props.article?.created_by?.id === author().id ||
|
||||||
|
session()?.user?.roles.includes('editor')),
|
||||||
)
|
)
|
||||||
|
|
||||||
const scrollToComments = (event) => {
|
const scrollToComments = (event) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user