Merge pull request #425 from Discours/hotfix/delete-reaction-in-profile
Add delete function to Comment component
This commit is contained in:
commit
4a1ad2b5af
|
@ -30,6 +30,7 @@ type Props = {
|
|||
showArticleLink?: boolean
|
||||
clickedReply?: (id: number) => void
|
||||
clickedReplyId?: number
|
||||
onDelete?: (id: number) => void
|
||||
}
|
||||
|
||||
export const Comment = (props: Props) => {
|
||||
|
@ -64,7 +65,10 @@ export const Comment = (props: Props) => {
|
|||
|
||||
if (isConfirmed) {
|
||||
await deleteReaction(props.comment.id)
|
||||
|
||||
// TODO: Учесть то что deleteReaction может вернуть error
|
||||
if (props.onDelete) {
|
||||
props.onDelete(props.comment.id)
|
||||
}
|
||||
await showSnackbar({ body: t('Comment successfully deleted') })
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
@ -127,9 +127,8 @@ export const AuthorView = (props: Props) => {
|
|||
}
|
||||
|
||||
createEffect(() => {
|
||||
const a = author()
|
||||
if (a) {
|
||||
fetchComments(a)
|
||||
if (author()) {
|
||||
fetchComments(author())
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -139,6 +138,9 @@ export const AuthorView = (props: Props) => {
|
|||
: getImageUrl('production/image/logo_image.png'),
|
||||
)
|
||||
const description = createMemo(() => getDescription(author()?.bio))
|
||||
const handleDeleteComment = (id: number) => {
|
||||
setCommented((prev) => prev.filter((comment) => comment.id !== id))
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={styles.authorPage}>
|
||||
|
@ -233,7 +235,14 @@ export const AuthorView = (props: Props) => {
|
|||
<div class="col-md-20 col-lg-18">
|
||||
<ul class={stylesArticle.comments}>
|
||||
<For each={commented()?.sort(byCreated).reverse()}>
|
||||
{(comment) => <Comment comment={comment} class={styles.comment} showArticleLink />}
|
||||
{(comment) => (
|
||||
<Comment
|
||||
comment={comment}
|
||||
class={styles.comment}
|
||||
showArticleLink={true}
|
||||
onDelete={(id) => handleDeleteComment(id)}
|
||||
/>
|
||||
)}
|
||||
</For>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -135,6 +135,7 @@ export const apiClient = {
|
|||
user?: string
|
||||
}): Promise<AuthorFollows> => {
|
||||
const response = await publicGraphQLClient.query(authorFollows, params).toPromise()
|
||||
console.log('!!! response:', response)
|
||||
return response.data.get_author_follows
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user