From 029cf1e1337857e2e12befd8fe2acc532c5f4c90 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Tue, 1 Aug 2023 15:43:44 -0700 Subject: [PATCH] feat: add object resolving --- src/lib/components/lemmy/post/PostVote.svelte | 1 + src/routes/search/+page.svelte | 49 +++++++++++++++---- src/routes/search/+page.ts | 8 +++ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/lib/components/lemmy/post/PostVote.svelte b/src/lib/components/lemmy/post/PostVote.svelte index c971220e..b18a5186 100644 --- a/src/lib/components/lemmy/post/PostVote.svelte +++ b/src/lib/components/lemmy/post/PostVote.svelte @@ -7,6 +7,7 @@ import type { Post } from 'lemmy-js-client' import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons' import { profile } from '$lib/auth.js' + import { slide } from 'svelte/transition' export let post: Post export let vote: number = 0 diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index 87cd1bc7..bc751989 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -10,6 +10,7 @@ import Post from '$lib/components/lemmy/post/Post.svelte' import UserItem from '$lib/components/lemmy/user/UserItem.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 type { CommentView, @@ -18,6 +19,8 @@ PostView, } from 'lemmy-js-client' 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 @@ -79,6 +82,32 @@

Search for something!

{:else} + {#await data.streamed.object} +
+ + Federating... +
+ {:then object} + {#if object} +
+ {#if object.community} + + {/if} + {#if object.post} + + {/if} + {#if object.comment} + + {/if} + {#if object.person} + + {/if} +
+ {/if} + {/await}
{#each data.results as result} {#if isPost(result)} @@ -93,13 +122,15 @@ {/each}
- { - $page.url.searchParams.set('page', p.detail.toString()) - goto($page.url, { - invalidateAll: true, - }) - }} - /> + {#if data.results.length > 0} + { + $page.url.searchParams.set('page', p.detail.toString()) + goto($page.url, { + invalidateAll: true, + }) + }} + /> + {/if} {/if} diff --git a/src/routes/search/+page.ts b/src/routes/search/+page.ts index 40cbda91..9fbfe21b 100644 --- a/src/routes/search/+page.ts +++ b/src/routes/search/+page.ts @@ -46,6 +46,14 @@ export async function load({ url }) { return { page: page, results: everything, + streamed: { + object: get(profile)?.jwt + ? getClient().resolveObject({ + auth: get(profile)!.jwt!, + q: query, + }) + : undefined, + }, } }