i forgot whatever i've been doing, i think i added an inbox
This commit is contained in:
1 parent
ef037349f0
commit
04704749b7
24 files changed
+307
-86
No files matched your search
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import type { Comment, Post } from 'lemmy-js-client'
|
||||
import { authData, getClient, user } from '$lib/lemmy.js'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { ToastType, addToast } from '$lib/components/ui/toasts/toasts.js'
|
||||
|
||||
export let postId: number
|
||||
export let parentId: number | undefined = undefined
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let newComment = ''
|
||||
let loading = false
|
||||
|
||||
async function submit() {
|
||||
if (!$user || !$authData || newComment == '') return
|
||||
|
||||
loading = true
|
||||
|
||||
try {
|
||||
const response = await getClient().createComment({
|
||||
auth: $authData.token,
|
||||
content: newComment,
|
||||
post_id: postId,
|
||||
parent_id: parentId,
|
||||
})
|
||||
dispatch('comment', response)
|
||||
|
||||
newComment = ''
|
||||
addToast(
|
||||
'Success',
|
||||
'Your comment was added. You may need to refresh to see it.',
|
||||
ToastType.success
|
||||
)
|
||||
} catch (err) {
|
||||
addToast('Error', 'Failed to comment.', ToastType.error)
|
||||
}
|
||||
|
||||
loading = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="max-w-lg flex flex-col gap-2">
|
||||
<textarea
|
||||
rows="3"
|
||||
class="w-full bg-slate-100 dark:bg-zinc-900 border border-slate-200
|
||||
dark:border-zinc-800 p-4 outline-none focus:border-black
|
||||
focus:dark:border-white transition-colors rounded-md"
|
||||
bind:value={newComment}
|
||||
/>
|
||||
<div class="w-24 ml-auto flex flex-row gap-2">
|
||||
<Button
|
||||
large
|
||||
on:click={submit}
|
||||
color={Color.accent}
|
||||
{loading}
|
||||
disabled={loading}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user