Read-it-later social network

fixed publicationsQuery w search, show message on empty return

authored by zeu.dev and committed by tangled.org ddbad17f 25645749

+10 -8
+1 -1
src/routes/+layout.svelte
··· 35 35 36 36 <QueryClientProvider client={queryClient}> 37 37 <SvelteQueryDevtools /> 38 - <div class="flex flex-col gap-8 w-screen h-full min-h-screen font-azeret"> 38 + <div class="flex flex-col gap-8 w-screen h-full min-h-screen font-azeret bg-[#283618] text-white"> 39 39 <header class="flex flex-col lg:flex-row lg:items-center w-full gap-4 px-8 py-4 border-b lg:border-none justify-between"> 40 40 <a href="/" class="text-2xl hover:text-shadow-md font-neco font-semibold">🥔 potatonet</a> 41 41
+9 -7
src/routes/+page.svelte
··· 11 11 let searchTerm = $state(""); 12 12 const debouncedSearchTerm = new Debounced(() => searchTerm, 500); 13 13 14 - const publicationsQuery =$derived( createInfiniteQuery(() => ({ 15 - queryKey: ["publications", debouncedSearchTerm.current], 14 + const publicationsQuery = createInfiniteQuery(() => ({ 15 + queryKey: ["publications", debouncedSearchTerm.current || undefined], 16 16 queryFn: async ({ pageParam }) => { 17 17 const query = ` 18 18 query GetPublications { 19 - siteStandardPublication(first: 20, after: "${pageParam}", where: { 19 + siteStandardPublication(first: 20, after: "${pageParam}", ${debouncedSearchTerm.current && `where: { 20 20 or: [{ 21 21 name: { contains: "${debouncedSearchTerm.current}" } 22 22 }, { 23 23 actorHandle: { contains: "${debouncedSearchTerm.current}" } 24 24 }] 25 - }) { 25 + }`}) { 26 26 edges {} 27 27 pageInfo { 28 28 hasNextPage ··· 42 42 } 43 43 } 44 44 }, 45 - staleTime: 1000000, 46 45 initialPageParam: "", 47 46 getNextPageParam: (lastPage) => lastPage.siteStandardPublication.pageInfo.endCursor, 48 47 select: (data) => { ··· 50 49 const nodes = items.map((i) => i.node); 51 50 return nodes; 52 51 } 53 - }))); 52 + })); 54 53 55 54 let currentPage = $derived(publicationsQuery.data?.slice(page*20, (page*20) + 20)); 56 55 </script> ··· 90 89 <p>Fetching...</p> 91 90 {:else if publicationsQuery.isError} 92 91 <p>Error</p> 93 - {:else} 92 + {:else if publicationsQuery.isSuccess} 93 + {#if currentPage?.length === 0} 94 + There are no publications based onb the current filters 95 + {/if} 94 96 {#each currentPage as publication (publication.uri)} 95 97 <PublicationCard {publication} /> 96 98 {/each}