[WiP] createReaction debug

This commit is contained in:
ilya-bkv 2022-12-23 10:08:17 +03:00
parent 3411a23cf7
commit 8d4b06277b
3 changed files with 5 additions and 30 deletions

View File

@ -41,10 +41,10 @@ export default (props: Props) => {
event.preventDefault()
// await createReaction({
await apiClient.createReaction({
kind: 7,
replyTo: props.parent,
body: postMessageText(),
shout: comment().shout.slug
shout: comment().shout.slug,
kind: 7
})
}
const formattedDate = createMemo(() =>
@ -168,9 +168,6 @@ export default (props: Props) => {
</Show>
</div>
</Show>
<Show when={props.children}>
<ul>{props.children}</ul>
</Show>
</li>
)
}

View File

@ -53,24 +53,6 @@ export const CommentsTree = (props: { shoutSlug: string }) => {
}
onMount(async () => await loadMore())
const nestComments = (commentList) => {
const commentMap = {}
commentList.forEach((comment) => {
commentMap[comment.id] = comment
if (comment.replyTo !== null) {
const parent = commentMap[comment.replyTo] ?? []
;(parent.children = parent.children || []).push(comment)
}
})
return commentList.filter((comment) => {
return !comment.replyTo
})
}
createEffect(() => {
console.log('!!! re:', nestComments(reactions()))
})
return (
<>
<Show when={!isCommentsLoading()} fallback={<Loading />}>
@ -106,16 +88,13 @@ export const CommentsTree = (props: { shoutSlug: string }) => {
</div>
<ul class={styles.comments}>
<For each={nestComments(reactions().reverse())}>
<For each={reactions().reverse()}>
{(reaction: NestedReaction) => (
<Comment
comment={reaction}
parent={reaction.id}
level={getCommentLevel(reaction)}
canEdit={reaction?.createdBy?.slug === session()?.user?.slug}
children={(reaction.children || []).map((r) => {
return <Comment comment={r} parent={reaction.id} />
})}
/>
)}
</For>

View File

@ -230,9 +230,8 @@ export const apiClient = {
console.debug('createArticle response:', response)
return response.data.createShout
},
createReaction: async (input: ReactionInput) => {
const response = await privateGraphQLClient.mutation(reactionCreate, { reaction: input }).toPromise()
console.log('!!! response:', response)
createReaction: async (reaction) => {
const response = await privateGraphQLClient.mutation(reactionCreate, { reaction: reaction }).toPromise()
return response.data
},