Merge branch 'dev' into feature/rating
This commit is contained in:
commit
372012badf
|
@ -136,7 +136,6 @@
|
||||||
"Each image must be no larger than 5 MB.": "Каждое изображение должно быть размером не больше 5 мб.",
|
"Each image must be no larger than 5 MB.": "Каждое изображение должно быть размером не больше 5 мб.",
|
||||||
"Edit profile": "Редактировать профиль",
|
"Edit profile": "Редактировать профиль",
|
||||||
"Edit": "Редактировать",
|
"Edit": "Редактировать",
|
||||||
"Edited": "Отредактирован",
|
|
||||||
"Editing": "Редактирование",
|
"Editing": "Редактирование",
|
||||||
"Editor": "Редактор",
|
"Editor": "Редактор",
|
||||||
"Email": "Почта",
|
"Email": "Почта",
|
||||||
|
|
|
@ -38,6 +38,7 @@ export const Comment = (props: Props) => {
|
||||||
const [loading, setLoading] = createSignal(false)
|
const [loading, setLoading] = createSignal(false)
|
||||||
const [editMode, setEditMode] = createSignal(false)
|
const [editMode, setEditMode] = createSignal(false)
|
||||||
const [clearEditor, setClearEditor] = createSignal(false)
|
const [clearEditor, setClearEditor] = createSignal(false)
|
||||||
|
const [editedBody, setEditedBody] = createSignal<string>()
|
||||||
const { author, session } = useSession()
|
const { author, session } = useSession()
|
||||||
const { createReaction, deleteReaction, updateReaction } = useReactions()
|
const { createReaction, deleteReaction, updateReaction } = useReactions()
|
||||||
const { showConfirm } = useConfirm()
|
const { showConfirm } = useConfirm()
|
||||||
|
@ -49,7 +50,7 @@ export const Comment = (props: Props) => {
|
||||||
(props.comment?.created_by?.slug === author().slug || session()?.user?.roles.includes('editor')),
|
(props.comment?.created_by?.slug === author().slug || session()?.user?.roles.includes('editor')),
|
||||||
)
|
)
|
||||||
|
|
||||||
const body = createMemo(() => (props.comment.body || '').trim())
|
const body = createMemo(() => (editedBody() ? editedBody().trim() : props.comment.body.trim() || ''))
|
||||||
|
|
||||||
const remove = async () => {
|
const remove = async () => {
|
||||||
if (props.comment?.id) {
|
if (props.comment?.id) {
|
||||||
|
@ -97,12 +98,15 @@ export const Comment = (props: Props) => {
|
||||||
const handleUpdate = async (value) => {
|
const handleUpdate = async (value) => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
await updateReaction({
|
const reaction = await updateReaction({
|
||||||
id: props.comment.id,
|
id: props.comment.id,
|
||||||
kind: ReactionKind.Comment,
|
kind: ReactionKind.Comment,
|
||||||
body: value,
|
body: value,
|
||||||
shout: props.comment.shout.id,
|
shout: props.comment.shout.id,
|
||||||
})
|
})
|
||||||
|
if (reaction) {
|
||||||
|
setEditedBody(value)
|
||||||
|
}
|
||||||
setEditMode(false)
|
setEditMode(false)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -165,7 +169,7 @@ export const Comment = (props: Props) => {
|
||||||
<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={props.comment.body}
|
initialContent={editedBody() || props.comment.body}
|
||||||
submitButtonText={t('Save')}
|
submitButtonText={t('Save')}
|
||||||
quoteEnabled={true}
|
quoteEnabled={true}
|
||||||
imageEnabled={true}
|
imageEnabled={true}
|
||||||
|
|
|
@ -18,15 +18,6 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.icon {
|
|
||||||
line-height: 1;
|
|
||||||
width: 1rem;
|
|
||||||
display: inline-block;
|
|
||||||
opacity: 0.6;
|
|
||||||
margin-right: 0.5rem;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.showOnHover {
|
&.showOnHover {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import type { Reaction } from '../../../graphql/schema/core.gen'
|
import type { Reaction } from '../../../graphql/schema/core.gen'
|
||||||
|
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { Show } from 'solid-js'
|
|
||||||
|
|
||||||
import { useLocalize } from '../../../context/localize'
|
import { useLocalize } from '../../../context/localize'
|
||||||
import { Icon } from '../../_shared/Icon'
|
|
||||||
|
|
||||||
import styles from './CommentDate.module.scss'
|
import styles from './CommentDate.module.scss'
|
||||||
|
|
||||||
|
@ -34,14 +32,6 @@ export const CommentDate = (props: Props) => {
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<time class={styles.date}>{formattedDate(props.comment.created_at * 1000)}</time>
|
<time class={styles.date}>{formattedDate(props.comment.created_at * 1000)}</time>
|
||||||
<Show when={props.comment.updated_at}>
|
|
||||||
<time class={styles.date}>
|
|
||||||
<Icon name="edit" class={styles.icon} />
|
|
||||||
<span class={styles.text}>
|
|
||||||
{t('Edited')} {formattedDate(props.comment.updated_at * 1000)}
|
|
||||||
</span>
|
|
||||||
</time>
|
|
||||||
</Show>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ type ReactionsContextType = {
|
||||||
offset?: number
|
offset?: number
|
||||||
}) => Promise<Reaction[]>
|
}) => Promise<Reaction[]>
|
||||||
createReaction: (reaction: ReactionInput) => Promise<void>
|
createReaction: (reaction: ReactionInput) => Promise<void>
|
||||||
updateReaction: (reaction: ReactionInput) => Promise<void>
|
updateReaction: (reaction: ReactionInput) => Promise<Reaction>
|
||||||
deleteReaction: (id: number) => Promise<void>
|
deleteReaction: (id: number) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
await apiClient.destroyReaction(reaction)
|
await apiClient.destroyReaction(reaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateReaction = async (input: ReactionInput): Promise<void> => {
|
const updateReaction = async (input: ReactionInput): Promise<Reaction> => {
|
||||||
const reaction = await apiClient.updateReaction(input)
|
const reaction = await apiClient.updateReaction(input)
|
||||||
setReactionEntities((rrr) => {
|
setReactionEntities((rrr) => {
|
||||||
rrr[reaction.id] = reaction
|
rrr[reaction.id] = reaction
|
||||||
|
|
Loading…
Reference in New Issue
Block a user