feat: Add login stuff

This commit is contained in:
Xyphyn committed 2023-07-04 13:08:58 -07:00
1 parent f71ad4be8e
commit f0523b0c3f
18 files changed
+288 -56

No files matched your search

-8
View File
@@ -1,8 +0,0 @@
<script lang="ts">
export let url: string
export let alt: string = ''
export let width: number
</script>
<img src={url} {alt} {width} class="rounded-full aspect-square object-cover" />
+5 -5
View File
@@ -7,7 +7,7 @@
Minus,
Plus,
} from 'svelte-hero-icons'
import Avatar from '../Avatar.svelte'
import Avatar from '../../../../lib/components/ui/Avatar.svelte'
import type { CommentNodeI } from '../comments.js'
import SvelteMarkdown from 'svelte-markdown'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
@@ -27,6 +27,8 @@
const upvoted = node.comment_view.my_vote == 1
node.comment_view.my_vote = Number(!upvoted)
await getClient()
.likeComment({
score: upvoted ? 0 : 1,
@@ -34,8 +36,6 @@
comment_id: node.comment_view.comment.id,
})
.catch((_) => undefined)
node.comment_view.my_vote = Number(!upvoted)
}
async function downvote() {
@@ -43,6 +43,8 @@
const upvoted = node.comment_view.my_vote == -1
node.comment_view.my_vote = -Number(!upvoted)
await getClient()
.likeComment({
score: upvoted ? 0 : -1,
@@ -50,8 +52,6 @@
comment_id: node.comment_view.comment.id,
})
.catch((_) => undefined)
node.comment_view.my_vote = -Number(!upvoted)
}
</script>
@@ -4,6 +4,7 @@
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
@@ -28,8 +29,13 @@
dispatch('comment', response)
newComment = ''
addToast(
'Success',
'Your comment was added. You may need to refresh to see it.',
ToastType.success
)
} catch (err) {
alert('Failed to comment')
addToast('Error', 'Failed to comment.', ToastType.error)
}
loading = false