diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index dea97099..5e5b61e9 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -136,7 +136,6 @@ "Each image must be no larger than 5 MB.": "Каждое изображение должно быть размером не больше 5 мб.", "Edit profile": "Редактировать профиль", "Edit": "Редактировать", - "Edited": "Отредактирован", "Editing": "Редактирование", "Editor": "Редактор", "Email": "Почта", diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index c8b49fdd..cf541ca3 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -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() 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) => { }> {t('Loading')}

}> { })} > - - - ) } diff --git a/src/context/reactions.tsx b/src/context/reactions.tsx index 1fe91de6..82e8e9ac 100644 --- a/src/context/reactions.tsx +++ b/src/context/reactions.tsx @@ -19,7 +19,7 @@ type ReactionsContextType = { offset?: number }) => Promise createReaction: (reaction: ReactionInput) => Promise - updateReaction: (reaction: ReactionInput) => Promise + updateReaction: (reaction: ReactionInput) => Promise deleteReaction: (id: number) => Promise } @@ -97,7 +97,7 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => { await apiClient.destroyReaction(reaction) } - const updateReaction = async (input: ReactionInput): Promise => { + const updateReaction = async (input: ReactionInput): Promise => { const reaction = await apiClient.updateReaction(input) setReactionEntities((rrr) => { rrr[reaction.id] = reaction