misc: switch to commentform for edit modal

This commit is contained in:
Xyphyn committed 2023-07-28 14:03:33 -07:00
1 parent f90ecb703c
commit 4cbb7381cb
2 files changed
+13 -6

No files matched your search

@@ -67,7 +67,10 @@
}} }}
> >
<span slot="title">Edit comment</span> <span slot="title">Edit comment</span>
<TextArea bind:value={newComment} /> <CommentForm
postId={node.comment_view.comment.id}
bind:value={newComment}
/>
</Modal> </Modal>
{/if} {/if}
@@ -13,24 +13,26 @@
const dispatch = createEventDispatcher<{ comment: CommentResponse }>() const dispatch = createEventDispatcher<{ comment: CommentResponse }>()
let newComment = '' export let value = ''
export let actions = true
let loading = false let loading = false
async function submit() { async function submit() {
if (!$user || !$authData || newComment == '') return if (!$user || !$authData || value == '') return
loading = true loading = true
try { try {
const response = await getClient().createComment({ const response = await getClient().createComment({
auth: $authData.token, auth: $authData.token,
content: newComment, content: value,
post_id: postId, post_id: postId,
parent_id: parentId, parent_id: parentId,
}) })
dispatch('comment', response) dispatch('comment', response)
newComment = '' value = ''
addToast( addToast(
'Success', 'Success',
'Your comment was added. You may need to refresh to see it.', 'Your comment was added. You may need to refresh to see it.',
@@ -54,9 +56,10 @@
rows={4} rows={4}
placeholder={locked ? 'This post is locked.' : 'What are you thinking?'} placeholder={locked ? 'This post is locked.' : 'What are you thinking?'}
class="!bg-slate-100 dark:!bg-zinc-900" class="!bg-slate-100 dark:!bg-zinc-900"
bind:value={newComment} bind:value
disabled={locked} disabled={locked}
/> />
{#if actions}
<div class="sm:ml-auto sm:w-28"> <div class="sm:ml-auto sm:w-28">
<Button <Button
large large
@@ -70,4 +73,5 @@
Submit Submit
</Button> </Button>
</div> </div>
{/if}
</div> </div>