From e0503f593f0e6ab5ee812b7d551bca6c60cc3e73 Mon Sep 17 00:00:00 2001
From: ilya-bkv
Date: Mon, 4 Mar 2024 11:54:09 +0300
Subject: [PATCH 1/3] Remove comment edited date
---
public/locales/ru/translation.json | 1 -
.../Article/CommentDate/CommentDate.module.scss | 11 +----------
src/components/Article/CommentDate/CommentDate.tsx | 10 ----------
3 files changed, 1 insertion(+), 21 deletions(-)
diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json
index 647917b0..8c93787b 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/CommentDate/CommentDate.module.scss b/src/components/Article/CommentDate/CommentDate.module.scss
index 18caedde..89d90585 100644
--- a/src/components/Article/CommentDate/CommentDate.module.scss
+++ b/src/components/Article/CommentDate/CommentDate.module.scss
@@ -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 {
diff --git a/src/components/Article/CommentDate/CommentDate.tsx b/src/components/Article/CommentDate/CommentDate.tsx
index e3901399..ff5bc9c5 100644
--- a/src/components/Article/CommentDate/CommentDate.tsx
+++ b/src/components/Article/CommentDate/CommentDate.tsx
@@ -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) => {
})}
>
-
-
-
)
}
From bc1ea821277b0c9f47e47a7b5ca6389021f5f95d Mon Sep 17 00:00:00 2001
From: ilya-bkv
Date: Mon, 4 Mar 2024 13:47:11 +0300
Subject: [PATCH 2/3] Fix comment edit without refresh
---
src/components/Article/Comment/Comment.tsx | 8 ++++++--
src/context/reactions.tsx | 5 +++--
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx
index d5b794e6..af60cf7d 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) {
diff --git a/src/context/reactions.tsx b/src/context/reactions.tsx
index ae4c7b95..f23c5044 100644
--- a/src/context/reactions.tsx
+++ b/src/context/reactions.tsx
@@ -18,7 +18,7 @@ type ReactionsContextType = {
offset?: number
}) => Promise
createReaction: (reaction: ReactionInput) => Promise
- updateReaction: (reaction: ReactionInput) => Promise
+ updateReaction: (reaction: ReactionInput) => Promise
deleteReaction: (id: number) => Promise
}
@@ -88,9 +88,10 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
}
}
- const updateReaction = async (input: ReactionInput): Promise => {
+ const updateReaction = async (input: ReactionInput): Promise => {
const reaction = await apiClient.updateReaction(input)
setReactionEntities(reaction.id, reaction)
+ return reaction
}
onCleanup(() => setReactionEntities(reconcile({})))
From 4196bb0f1ef80296e374618bd27f4d089ba9caeb Mon Sep 17 00:00:00 2001
From: ilya-bkv
Date: Mon, 4 Mar 2024 15:18:24 +0300
Subject: [PATCH 3/3] Fix comment edit without refresh (update editor state)
---
src/components/Article/Comment/Comment.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx
index af60cf7d..445d4944 100644
--- a/src/components/Article/Comment/Comment.tsx
+++ b/src/components/Article/Comment/Comment.tsx
@@ -169,7 +169,7 @@ export const Comment = (props: Props) => {
}>
{t('Loading')}
}>