This commit is contained in:
Xylight committed 2023-11-14 17:41:34 -08:00
1 parent a6249dba60
commit 47e20d9ca3
2 files changed
+32 -11

No files matched your search

+26 -10
View File
@@ -30,15 +30,14 @@
let editing = false let editing = false
let newComment = node.comment_view.comment.content let newComment = node.comment_view.comment.content
</script>
{#if editing} let editingLoad = false
<Modal
bind:open={editing} async function save() {
action="Save"
on:action={async () => {
if (!$profile?.jwt || newComment.length <= 0) return if (!$profile?.jwt || newComment.length <= 0) return
editingLoad = true
try { try {
await getClient().editComment({ await getClient().editComment({
comment_id: node.comment_view.comment.id, comment_id: node.comment_view.comment.id,
@@ -50,8 +49,7 @@
editing = false editing = false
toast({ toast({
content: content: 'Successfully edited comment.',
'Successfully edited comment. You may need to refresh to see changes.',
type: 'success', type: 'success',
}) })
} catch (err) { } catch (err) {
@@ -61,15 +59,33 @@
type: 'error', type: 'error',
}) })
} }
}}
> editingLoad = false
}
</script>
{#if editing}
<Modal bind:open={editing}>
<span slot="title">Edit comment</span> <span slot="title">Edit comment</span>
<form on:submit|preventDefault={save} class="contents">
<CommentForm <CommentForm
postId={node.comment_view.comment.id} postId={node.comment_view.comment.id}
bind:value={newComment} bind:value={newComment}
actions={false} actions={false}
preview={true} preview={true}
on:confirm={save}
/> />
<Button
submit
color="primary"
size="lg"
loading={editingLoad}
disabled={editingLoad}
class="w-full"
>
Save
</Button>
</form>
</Modal> </Modal>
{/if} {/if}
@@ -70,7 +70,12 @@
: placeholders.get('comment')} : placeholders.get('comment')}
bind:value bind:value
disabled={locked || loading} disabled={locked || loading}
on:confirm={submit} on:confirm={() => {
if (actions) {
submit()
}
}}
on:confirm
previewButton={previewAction} previewButton={previewAction}
> >
{#if actions} {#if actions}