From 9361dfb8a63477006a4cd1c06480027bab2e92e1 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Sat, 26 Jul 2025 17:12:44 -0700 Subject: [PATCH] feat: add remote instance subscribing --- .../lemmy/community/CommunityItem.svelte | 16 +++++++++++++++- src/routes/communities/+page.svelte | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib/components/lemmy/community/CommunityItem.svelte b/src/lib/components/lemmy/community/CommunityItem.svelte index 2e9acd8c..74bb2195 100644 --- a/src/lib/components/lemmy/community/CommunityItem.svelte +++ b/src/lib/components/lemmy/community/CommunityItem.svelte @@ -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() @@ -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 = diff --git a/src/routes/communities/+page.svelte b/src/routes/communities/+page.svelte index 4e80eb84..09c9278f 100644 --- a/src/routes/communities/+page.svelte +++ b/src/routes/communities/+page.svelte @@ -177,7 +177,11 @@ {@const sliced = data.communities.value.slice(showTop ? 3 : 0)} {#snippet item(community)} - + {/snippet} {/if}