Comment fixies (#256)

This commit is contained in:
Ilya Y 2023-10-12 17:18:01 +03:00 committed by GitHub
parent d2c6f94c33
commit c9febc75ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -36,8 +36,9 @@ type Props = {
export const Comment = (props: Props) => {
const { t } = useLocalize()
const [isReplyVisible, setIsReplyVisible] = createSignal(false)
const [loading, setLoading] = createSignal<boolean>(false)
const [editMode, setEditMode] = createSignal<boolean>(false)
const [loading, setLoading] = createSignal(false)
const [editMode, setEditMode] = createSignal(false)
const [clearEditor, setClearEditor] = createSignal(false)
const { session } = useSession()
const {
@ -81,11 +82,13 @@ export const Comment = (props: Props) => {
body: value,
shout: props.comment.shout.id
})
setClearEditor(true)
setIsReplyVisible(false)
setLoading(false)
} catch (error) {
console.error('[handleCreate reaction]:', error)
}
setClearEditor(false)
}
const toggleEditMode = () => {
@ -175,11 +178,13 @@ export const Comment = (props: Props) => {
<SimplifiedEditor
initialContent={comment().body}
submitButtonText={t('Save')}
submitByEnter={true}
quoteEnabled={true}
imageEnabled={true}
placeholder={t('Write a comment...')}
onSubmit={(value) => handleUpdate(value)}
submitByShiftEnter={true}
setClear={clearEditor()}
/>
</Suspense>
</Show>

View File

@ -33,7 +33,7 @@ const sortCommentsByRating = (a: Reaction, b: Reaction): -1 | 0 | 1 => {
}
type Props = {
commentAuthors: Author[]
articleAuthors: Author[]
shoutSlug: string
shoutId: number
}
@ -149,7 +149,9 @@ export const CommentsTree = (props: Props) => {
{(reaction) => (
<Comment
sortedComments={sortedComments()}
isArticleAuthor={Boolean(props.commentAuthors.some((a) => a.slug === session()?.user.slug))}
isArticleAuthor={Boolean(
props.articleAuthors.some((a) => a.slug === reaction.createdBy.slug)
)}
comment={reaction}
lastSeen={dateFromLocalStorage}
/>

View File

@ -431,7 +431,7 @@ export const FullArticle = (props: Props) => {
<CommentsTree
shoutId={props.article.id}
shoutSlug={props.article.slug}
commentAuthors={props.article.authors}
articleAuthors={props.article.authors}
/>
</Show>
</div>