Refactor Comment component and improve debug logging

Implemented a delete function in the Comment component that filters out the selected comment in real time, enhancing the user experience by providing immediate feedback upon deletion. Also, refactor the authorFollows function in the GraphQL client core to use standardized string quotations for better code consistency.
This commit is contained in:
ilya-bkv 2024-03-06 15:02:32 +03:00
parent eb03dc1d05
commit 45e8f2ba02
3 changed files with 4 additions and 6 deletions

View File

@ -71,8 +71,6 @@ export const Comment = (props: Props) => {
}
await showSnackbar({ body: t('Comment successfully deleted') })
}
} catch (error) {
console.error('[deleteReaction]', error)
}

View File

@ -139,7 +139,7 @@ export const AuthorView = (props: Props) => {
)
const description = createMemo(() => getDescription(author()?.bio))
const handleDeleteComment = (id: number) => {
setCommented((prev) => prev.filter((comment) => comment.id !== id));
setCommented((prev) => prev.filter((comment) => comment.id !== id))
}
return (
@ -235,14 +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={comment}
class={styles.comment}
showArticleLink={true}
onDelete={(id) => handleDeleteComment(id)}
/>
}
)}
</For>
</ul>
</div>

View File

@ -135,7 +135,7 @@ export const apiClient = {
user?: string
}): Promise<AuthorFollows> => {
const response = await publicGraphQLClient.query(authorFollows, params).toPromise()
console.log("!!! response:", response);
console.log('!!! response:', response)
return response.data.get_author_follows
},