feat: add externalInteraction page, close #489

This commit is contained in:
James Xylight committed 2025-02-09 09:54:42 -08:00
1 parent e084658c28
commit 5aebb5639f
3 files changed
+57 -1

No files matched your search

@@ -0,0 +1,36 @@
<script lang="ts">
import { t } from '$lib/translations'
import { Spinner } from 'mono-svelte'
import type { ResolveObjectResponse } from 'lemmy-js-client'
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
import UserItem from '$lib/components/lemmy/user/UserItem.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
interface Props {
data: {
resolved: Promise<ResolveObjectResponse>
}
}
let { data }: Props = $props()
</script>
<div class="flex flex-col items-center justify-center h-full gap-3">
{#await data.resolved}
<Spinner width={32} />
<span class="font-medium text-lg">{$t('routes.search.federating')}...</span>
{:then object}
<div class="w-full max-w-md">
{#if object.community}
<CommunityItem bind:community={object.community} />
{:else if object.person}
<UserItem user={object.person} />
{:else if object.post}
<Post post={object.post} />
{:else if object.comment}
<CommentItem comment={object.comment} />
{/if}
</div>
{/await}
</div>
@@ -0,0 +1,19 @@
import { profile } from '$lib/auth.svelte.js'
import { client } from '$lib/lemmy.js'
import { error, redirect } from '@sveltejs/kit'
export const ssr = false
export async function load({ fetch, url }) {
const uri = url.searchParams.get('uri')
if (!uri) error(404)
if (!profile.data.jwt)
redirect(302, `/login?ref=${encodeURIComponent(url.toString())}`)
return {
resolved: client({ func: fetch }).resolveObject({
q: uri,
}),
}
}