Comment fixies (#256)
This commit is contained in:
parent
d2c6f94c33
commit
c9febc75ea
|
@ -36,8 +36,9 @@ type Props = {
|
||||||
export const Comment = (props: Props) => {
|
export const Comment = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const [isReplyVisible, setIsReplyVisible] = createSignal(false)
|
const [isReplyVisible, setIsReplyVisible] = createSignal(false)
|
||||||
const [loading, setLoading] = createSignal<boolean>(false)
|
const [loading, setLoading] = createSignal(false)
|
||||||
const [editMode, setEditMode] = createSignal<boolean>(false)
|
const [editMode, setEditMode] = createSignal(false)
|
||||||
|
const [clearEditor, setClearEditor] = createSignal(false)
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -81,11 +82,13 @@ export const Comment = (props: Props) => {
|
||||||
body: value,
|
body: value,
|
||||||
shout: props.comment.shout.id
|
shout: props.comment.shout.id
|
||||||
})
|
})
|
||||||
|
setClearEditor(true)
|
||||||
setIsReplyVisible(false)
|
setIsReplyVisible(false)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[handleCreate reaction]:', error)
|
console.error('[handleCreate reaction]:', error)
|
||||||
}
|
}
|
||||||
|
setClearEditor(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleEditMode = () => {
|
const toggleEditMode = () => {
|
||||||
|
@ -175,11 +178,13 @@ export const Comment = (props: Props) => {
|
||||||
<SimplifiedEditor
|
<SimplifiedEditor
|
||||||
initialContent={comment().body}
|
initialContent={comment().body}
|
||||||
submitButtonText={t('Save')}
|
submitButtonText={t('Save')}
|
||||||
|
submitByEnter={true}
|
||||||
quoteEnabled={true}
|
quoteEnabled={true}
|
||||||
imageEnabled={true}
|
imageEnabled={true}
|
||||||
placeholder={t('Write a comment...')}
|
placeholder={t('Write a comment...')}
|
||||||
onSubmit={(value) => handleUpdate(value)}
|
onSubmit={(value) => handleUpdate(value)}
|
||||||
submitByShiftEnter={true}
|
submitByShiftEnter={true}
|
||||||
|
setClear={clearEditor()}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
|
@ -33,7 +33,7 @@ const sortCommentsByRating = (a: Reaction, b: Reaction): -1 | 0 | 1 => {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
commentAuthors: Author[]
|
articleAuthors: Author[]
|
||||||
shoutSlug: string
|
shoutSlug: string
|
||||||
shoutId: number
|
shoutId: number
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,9 @@ export const CommentsTree = (props: Props) => {
|
||||||
{(reaction) => (
|
{(reaction) => (
|
||||||
<Comment
|
<Comment
|
||||||
sortedComments={sortedComments()}
|
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}
|
comment={reaction}
|
||||||
lastSeen={dateFromLocalStorage}
|
lastSeen={dateFromLocalStorage}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -431,7 +431,7 @@ export const FullArticle = (props: Props) => {
|
||||||
<CommentsTree
|
<CommentsTree
|
||||||
shoutId={props.article.id}
|
shoutId={props.article.id}
|
||||||
shoutSlug={props.article.slug}
|
shoutSlug={props.article.slug}
|
||||||
commentAuthors={props.article.authors}
|
articleAuthors={props.article.authors}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user