parent
0d1aaebfa5
commit
8b066104e6
|
@ -46,14 +46,13 @@ export const Comment = (props: Props) => {
|
||||||
const canEdit = createMemo(
|
const canEdit = createMemo(
|
||||||
() =>
|
() =>
|
||||||
Boolean(author()?.id) &&
|
Boolean(author()?.id) &&
|
||||||
(props.comment?.created_by?.id === author().id || session()?.user?.roles.includes('editor')),
|
(props.comment?.created_by?.slug === author().slug || session()?.user?.roles.includes('editor')),
|
||||||
)
|
)
|
||||||
|
|
||||||
const comment = createMemo(() => props.comment)
|
const body = createMemo(() => (props.comment.body || '').trim())
|
||||||
const body = createMemo(() => (comment().body || '').trim())
|
|
||||||
|
|
||||||
const remove = async () => {
|
const remove = async () => {
|
||||||
if (comment()?.id) {
|
if (props.comment?.id) {
|
||||||
try {
|
try {
|
||||||
const isConfirmed = await showConfirm({
|
const isConfirmed = await showConfirm({
|
||||||
confirmBody: t('Are you sure you want to delete this comment?'),
|
confirmBody: t('Are you sure you want to delete this comment?'),
|
||||||
|
@ -63,7 +62,7 @@ export const Comment = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isConfirmed) {
|
if (isConfirmed) {
|
||||||
await deleteReaction(comment().id)
|
await deleteReaction(props.comment.id)
|
||||||
|
|
||||||
await showSnackbar({ body: t('Comment successfully deleted') })
|
await showSnackbar({ body: t('Comment successfully deleted') })
|
||||||
}
|
}
|
||||||
|
@ -113,8 +112,10 @@ export const Comment = (props: Props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
id={`comment_${comment().id}`}
|
id={`comment_${props.comment.id}`}
|
||||||
class={clsx(styles.comment, props.class, { [styles.isNew]: comment()?.created_at > props.lastSeen })}
|
class={clsx(styles.comment, props.class, {
|
||||||
|
[styles.isNew]: props.comment?.created_at > props.lastSeen,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Show when={!!body()}>
|
<Show when={!!body()}>
|
||||||
<div class={styles.commentContent}>
|
<div class={styles.commentContent}>
|
||||||
|
@ -123,21 +124,21 @@ export const Comment = (props: Props) => {
|
||||||
fallback={
|
fallback={
|
||||||
<div>
|
<div>
|
||||||
<Userpic
|
<Userpic
|
||||||
name={comment().created_by.name}
|
name={props.comment.created_by.name}
|
||||||
userpic={comment().created_by.pic}
|
userpic={props.comment.created_by.pic}
|
||||||
class={clsx({
|
class={clsx({
|
||||||
[styles.compactUserpic]: props.compact,
|
[styles.compactUserpic]: props.compact,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<small>
|
<small>
|
||||||
<a href={`#comment_${comment()?.id}`}>{comment()?.shout.title || ''}</a>
|
<a href={`#comment_${props.comment?.id}`}>{props.comment?.shout.title || ''}</a>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div class={styles.commentDetails}>
|
<div class={styles.commentDetails}>
|
||||||
<div class={styles.commentAuthor}>
|
<div class={styles.commentAuthor}>
|
||||||
<AuthorLink author={comment()?.created_by as Author} />
|
<AuthorLink author={props.comment?.created_by as Author} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Show when={props.isArticleAuthor}>
|
<Show when={props.isArticleAuthor}>
|
||||||
|
@ -148,23 +149,23 @@ export const Comment = (props: Props) => {
|
||||||
<div class={styles.articleLink}>
|
<div class={styles.articleLink}>
|
||||||
<Icon name="arrow-right" class={styles.articleLinkIcon} />
|
<Icon name="arrow-right" class={styles.articleLinkIcon} />
|
||||||
<a
|
<a
|
||||||
href={`${getPagePath(router, 'article', { slug: comment().shout.slug })}?commentId=${
|
href={`${getPagePath(router, 'article', {
|
||||||
comment().id
|
slug: props.comment.shout.slug,
|
||||||
}`}
|
})}?commentId=${props.comment.id}`}
|
||||||
>
|
>
|
||||||
{comment().shout.title}
|
{props.comment.shout.title}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
<CommentDate showOnHover={true} comment={comment()} isShort={true} />
|
<CommentDate showOnHover={true} comment={props.comment} isShort={true} />
|
||||||
<CommentRatingControl comment={comment()} />
|
<CommentRatingControl comment={props.comment} />
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
<div class={styles.commentBody}>
|
<div class={styles.commentBody}>
|
||||||
<Show when={editMode()} fallback={<div innerHTML={body()} />}>
|
<Show when={editMode()} fallback={<div innerHTML={body()} />}>
|
||||||
<Suspense fallback={<p>{t('Loading')}</p>}>
|
<Suspense fallback={<p>{t('Loading')}</p>}>
|
||||||
<SimplifiedEditor
|
<SimplifiedEditor
|
||||||
initialContent={comment().body}
|
initialContent={props.comment.body}
|
||||||
submitButtonText={t('Save')}
|
submitButtonText={t('Save')}
|
||||||
quoteEnabled={true}
|
quoteEnabled={true}
|
||||||
imageEnabled={true}
|
imageEnabled={true}
|
||||||
|
|
|
@ -3,12 +3,12 @@ import { For, Show, createEffect, createSignal, on, onMount } from 'solid-js'
|
||||||
import { useFollowing } from '../../context/following'
|
import { useFollowing } from '../../context/following'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
import { apiClient } from '../../graphql/client/core'
|
import { apiClient } from '../../graphql/client/core'
|
||||||
|
import { Author } from '../../graphql/schema/core.gen'
|
||||||
import { setAuthorsByFollowers, setAuthorsByShouts, useAuthorsStore } from '../../stores/zine/authors'
|
import { setAuthorsByFollowers, setAuthorsByShouts, useAuthorsStore } from '../../stores/zine/authors'
|
||||||
import { AuthorBadge } from '../Author/AuthorBadge'
|
import { AuthorBadge } from '../Author/AuthorBadge'
|
||||||
import { InlineLoader } from '../InlineLoader'
|
import { InlineLoader } from '../InlineLoader'
|
||||||
import { Button } from '../_shared/Button'
|
import { Button } from '../_shared/Button'
|
||||||
import styles from './AuthorsList.module.scss'
|
import styles from './AuthorsList.module.scss'
|
||||||
import { Author } from "../../graphql/schema/core.gen";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
class?: string
|
class?: string
|
||||||
|
@ -21,8 +21,9 @@ const PAGE_SIZE = 20
|
||||||
|
|
||||||
// TODO: проверить нет ли дубликатов в базе данных, если нет - то не использовать addUniqueAuthors()
|
// TODO: проверить нет ли дубликатов в базе данных, если нет - то не использовать addUniqueAuthors()
|
||||||
const addUniqueAuthors = (prevAuthors: Author[], newAuthors: Author[]) => {
|
const addUniqueAuthors = (prevAuthors: Author[], newAuthors: Author[]) => {
|
||||||
const uniqueNewAuthors = newAuthors.filter(newAuthor =>
|
const uniqueNewAuthors = newAuthors.filter(
|
||||||
!prevAuthors.some(prevAuthor => prevAuthor.id === newAuthor.id));
|
(newAuthor) => !prevAuthors.some((prevAuthor) => prevAuthor.id === newAuthor.id),
|
||||||
|
)
|
||||||
return [...prevAuthors, ...uniqueNewAuthors]
|
return [...prevAuthors, ...uniqueNewAuthors]
|
||||||
}
|
}
|
||||||
export const AuthorsList = (props: Props) => {
|
export const AuthorsList = (props: Props) => {
|
||||||
|
@ -43,9 +44,9 @@ export const AuthorsList = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (queryType === 'shouts') {
|
if (queryType === 'shouts') {
|
||||||
setAuthorsByShouts(prev => addUniqueAuthors(prev, result));
|
setAuthorsByShouts((prev) => addUniqueAuthors(prev, result))
|
||||||
} else {
|
} else {
|
||||||
setAuthorsByFollowers(prev => addUniqueAuthors(prev, result));
|
setAuthorsByFollowers((prev) => addUniqueAuthors(prev, result))
|
||||||
}
|
}
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,9 @@ export const MODALS: Record<ModalType, ModalType> = {
|
||||||
|
|
||||||
const [modal, setModal] = createSignal<ModalType>(null)
|
const [modal, setModal] = createSignal<ModalType>(null)
|
||||||
|
|
||||||
const { changeSearchParams, clearSearchParams } = useRouter<AuthModalSearchParams & ConfirmEmailSearchParams & RootSearchParams>()
|
const { changeSearchParams, clearSearchParams } = useRouter<
|
||||||
|
AuthModalSearchParams & ConfirmEmailSearchParams & RootSearchParams
|
||||||
|
>()
|
||||||
|
|
||||||
export const showModal = (modalType: ModalType, modalSource?: AuthModalSource) => {
|
export const showModal = (modalType: ModalType, modalSource?: AuthModalSource) => {
|
||||||
if (modalSource) {
|
if (modalSource) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user