feat: Add user pages

This commit is contained in:
Xyphyn committed 2023-07-04 19:39:27 -07:00
1 parent 04704749b7
commit 9efe1df0c2
12 files changed
+222 -29

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
<script lang="ts">
import { getClient } from '$lib/lemmy.js'
import type {
Community,
CommunityView,
SubscribedType,
} from 'lemmy-js-client'
import { authData } from '$lib/lemmy.js'
import { ToastType, addToast } from '$lib/components/ui/toasts/toasts.js'
export let community: CommunityView
let subscribing = false
async function subscribe() {
if (!$authData?.token) return
subscribing = true
try {
const res = await getClient().followCommunity({
auth: $authData.token,
community_id: community.community.id,
follow: community.subscribed == 'NotSubscribed',
})
subscribing = false
return res
} catch (error) {
addToast('Error', 'Failed to subscribe to community', ToastType.error)
}
subscribing = false
}
</script>
<slot {subscribe} {subscribing} />