feat: add remote instance subscribing

This commit is contained in:
James Xylight committed 2025-07-26 17:12:44 -07:00
1 parent 5e1d34cf2a
commit 9361dfb8a6
2 files changed
+20 -2

No files matched your search

@@ -22,6 +22,7 @@
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
import { settings } from '$lib/settings.svelte'
import type { Snippet } from 'svelte'
import { client } from '$lib/lemmy.svelte'
let showInfo = $state(false)
interface Props {
@@ -31,6 +32,7 @@
class?: string
icon?: import('svelte').Snippet
children?: Snippet
resolveObject?: boolean
}
let {
@@ -40,6 +42,7 @@
class: clazz = 'flex flex-col gap-4 text-sm max-w-full relative',
icon,
children,
resolveObject,
}: Props = $props()
</script>
@@ -160,7 +163,18 @@
disabled={subscribing || !profile.current?.jwt}
loading={subscribing}
onclick={async () => {
const res = await subscribe()
const object =
resolveObject &&
(await client().resolveObject({
q: `!${community.community.name}@${new URL(community.community.actor_id).hostname}`,
}))
const res = object
? await subscribe(
object.community?.community.id,
'NotSubscribed',
)
: await subscribe()
if (res) {
const newSubscribed =
+5 -1
View File
@@ -177,7 +177,11 @@
{@const sliced = data.communities.value.slice(showTop ? 3 : 0)}
<CommonList items={sliced}>
{#snippet item(community)}
<CommunityItem {community} showCounts={false} />
<CommunityItem
{community}
resolveObject={data.type.startsWith('instance-')}
showCounts={false}
/>
{/snippet}
</CommonList>
{/if}