feat: add object resolving
This commit is contained in:
1 parent
62f2eebddc
commit
029cf1e133
3 files changed
+40
No files matched your search
@@ -7,6 +7,7 @@
|
|||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
|
import { slide } from 'svelte/transition'
|
||||||
|
|
||||||
export let post: Post
|
export let post: Post
|
||||||
export let vote: number = 0
|
export let vote: number = 0
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import UserItem from '$lib/components/lemmy/user/UserItem.svelte'
|
import UserItem from '$lib/components/lemmy/user/UserItem.svelte'
|
||||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
|
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||||
import { isComment, isCommunity, isPost, isUser } from '$lib/lemmy/item.js'
|
import { isComment, isCommunity, isPost, isUser } from '$lib/lemmy/item.js'
|
||||||
import type {
|
import type {
|
||||||
CommentView,
|
CommentView,
|
||||||
@@ -18,6 +19,8 @@
|
|||||||
PostView,
|
PostView,
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
import { Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
import { Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
||||||
|
import { expoInOut, expoOut } from 'svelte/easing'
|
||||||
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
|
||||||
type Result = PostView | CommentView | PersonView | CommunityView
|
type Result = PostView | CommentView | PersonView | CommunityView
|
||||||
|
|
||||||
@@ -79,6 +82,32 @@
|
|||||||
<p class="mt-2 text-center">Search for something!</p>
|
<p class="mt-2 text-center">Search for something!</p>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
{#await data.streamed.object}
|
||||||
|
<div
|
||||||
|
class="flex gap-4 items-center mt-4"
|
||||||
|
out:slide={{ axis: 'y', easing: expoOut }}
|
||||||
|
>
|
||||||
|
<Spinner width={24} />
|
||||||
|
<span>Federating...</span>
|
||||||
|
</div>
|
||||||
|
{:then object}
|
||||||
|
{#if object}
|
||||||
|
<div transition:slide={{ axis: 'y', easing: expoOut }}>
|
||||||
|
{#if object.community}
|
||||||
|
<CommunityItem community={object.community} />
|
||||||
|
{/if}
|
||||||
|
{#if object.post}
|
||||||
|
<Post post={object.post} />
|
||||||
|
{/if}
|
||||||
|
{#if object.comment}
|
||||||
|
<CommentItem comment={object.comment} />
|
||||||
|
{/if}
|
||||||
|
{#if object.person}
|
||||||
|
<UserItem user={object.person} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/await}
|
||||||
<div class="flex flex-col gap-4 mt-4">
|
<div class="flex flex-col gap-4 mt-4">
|
||||||
{#each data.results as result}
|
{#each data.results as result}
|
||||||
{#if isPost(result)}
|
{#if isPost(result)}
|
||||||
@@ -93,6 +122,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4" />
|
<div class="mt-4" />
|
||||||
|
{#if data.results.length > 0}
|
||||||
<Pageination
|
<Pageination
|
||||||
bind:page={pageNum}
|
bind:page={pageNum}
|
||||||
on:change={(p) => {
|
on:change={(p) => {
|
||||||
@@ -102,4 +132,5 @@
|
|||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -46,6 +46,14 @@ export async function load({ url }) {
|
|||||||
return {
|
return {
|
||||||
page: page,
|
page: page,
|
||||||
results: everything,
|
results: everything,
|
||||||
|
streamed: {
|
||||||
|
object: get(profile)?.jwt
|
||||||
|
? getClient().resolveObject({
|
||||||
|
auth: get(profile)!.jwt!,
|
||||||
|
q: query,
|
||||||
|
})
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user