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 мб.",
|
||||
"Edit profile": "Редактировать профиль",
|
||||
"Edit": "Редактировать",
|
||||
"Edited": "Отредактирован",
|
||||
"Editing": "Редактирование",
|
||||
"Editor": "Редактор",
|
||||
"Email": "Почта",
|
||||
|
|
|
@ -38,6 +38,7 @@ export const Comment = (props: Props) => {
|
|||
const [loading, setLoading] = createSignal(false)
|
||||
const [editMode, setEditMode] = createSignal(false)
|
||||
const [clearEditor, setClearEditor] = createSignal(false)
|
||||
const [editedBody, setEditedBody] = createSignal<string>()
|
||||
const { author, session } = useSession()
|
||||
const { createReaction, deleteReaction, updateReaction } = useReactions()
|
||||
const { showConfirm } = useConfirm()
|
||||
|
@ -49,7 +50,7 @@ export const Comment = (props: Props) => {
|
|||
(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 () => {
|
||||
if (props.comment?.id) {
|
||||
|
@ -97,12 +98,15 @@ export const Comment = (props: Props) => {
|
|||
const handleUpdate = async (value) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await updateReaction({
|
||||
const reaction = await updateReaction({
|
||||
id: props.comment.id,
|
||||
kind: ReactionKind.Comment,
|
||||
body: value,
|
||||
shout: props.comment.shout.id,
|
||||
})
|
||||
if (reaction) {
|
||||
setEditedBody(value)
|
||||
}
|
||||
setEditMode(false)
|
||||
setLoading(false)
|
||||
} catch (error) {
|
||||
|
@ -165,7 +169,7 @@ export const Comment = (props: Props) => {
|
|||
<Show when={editMode()} fallback={<div innerHTML={body()} />}>
|
||||
<Suspense fallback={<p>{t('Loading')}</p>}>
|
||||
<SimplifiedEditor
|
||||
initialContent={props.comment.body}
|
||||
initialContent={editedBody() || props.comment.body}
|
||||
submitButtonText={t('Save')}
|
||||
quoteEnabled={true}
|
||||
imageEnabled={true}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@include font-size(1.2rem);
|
||||
|
||||
color: var(--secondary-color);
|
||||
|
||||
|
||||
// align-self: center;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
@ -18,15 +18,6 @@
|
|||
font-weight: 500;
|
||||
margin-right: 1rem;
|
||||
position: relative;
|
||||
|
||||
.icon {
|
||||
line-height: 1;
|
||||
width: 1rem;
|
||||
display: inline-block;
|
||||
opacity: 0.6;
|
||||
margin-right: 0.5rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
&.showOnHover {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import type { Reaction } from '../../../graphql/schema/core.gen'
|
||||
|
||||
import { clsx } from 'clsx'
|
||||
import { Show } from 'solid-js'
|
||||
|
||||
import { useLocalize } from '../../../context/localize'
|
||||
import { Icon } from '../../_shared/Icon'
|
||||
|
||||
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>
|
||||
<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>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ type ReactionsContextType = {
|
|||
offset?: number
|
||||
}) => Promise<Reaction[]>
|
||||
createReaction: (reaction: ReactionInput) => Promise<void>
|
||||
updateReaction: (reaction: ReactionInput) => Promise<void>
|
||||
updateReaction: (reaction: ReactionInput) => Promise<Reaction>
|
||||
deleteReaction: (id: number) => Promise<void>
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
|||
await apiClient.destroyReaction(reaction)
|
||||
}
|
||||
|
||||
const updateReaction = async (input: ReactionInput): Promise<void> => {
|
||||
const updateReaction = async (input: ReactionInput): Promise<Reaction> => {
|
||||
const reaction = await apiClient.updateReaction(input)
|
||||
setReactionEntities((rrr) => {
|
||||
rrr[reaction.id] = reaction
|
||||
|
|
Loading…
Reference in New Issue
Block a user