diff --git a/README.md b/README.md index a579c1f..75bcab4 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,17 @@ Get started at [potatonet.app](https://potatonet.app) 🥔 -- [ ] `//bookmarks`: bookmarks per user - - [x] fetch bookmarks - - [x] filter by query term - - [x] refresh bookmarks - - [x] filter by tags - - [ ] pagination -- [ ] atproto auth +- [x] atproto auth - [x] login/logout - - [ ] bookmark CRUD -- [x] explore - - [x] query all bookmarks - - [x] filter explore - - [ ] pagination +- [ ] site.standard.* + - [x] query all standard.site publications - [ ] search bar `/search?q=` +- [ ] community.lexicon.bookmarks + - [ ] publications + - [ ] documents +- [ ] community.lexicon.like + - [ ] publications + - [ ] documents > Special thanks to [pilcrowonpaper](https://pilcrowonpaper.com) for `@oslojs/encoding` library and the [encryption gist](https://gist.github.com/pilcrowonpaper/353318556029221c8e25f451b91e5f76) that the `encryption.ts` file is based on. diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e2749cc..8073db2 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -5,6 +5,8 @@ let { data } = $props(); let { atclient, user } = data; + let page = $state(0); + const publicationsQuery = createInfiniteQuery(() => ({ queryKey: ["publications"], queryFn: async ({ pageParam }) => { @@ -32,22 +34,50 @@ }, staleTime: 1000000, initialPageParam: "", - getNextPageParam: (lastPage) => lastPage.siteStandardPublication.pageInfo.endCursor + getNextPageParam: (lastPage) => lastPage.siteStandardPublication.pageInfo.endCursor, + select: (data) => { + const items = data.pages.map((page) => page.siteStandardPublication.edges).flat(); + const nodes = items.map((i) => i.node); + return nodes; + } })); + + let currentPage = $derived(publicationsQuery.data?.slice(page*20, (page*20) + 20)); + + + {page + 1} + {#if publicationsQuery.hasNextPage} + + {/if} + {#if publicationsQuery.isFetching}

Fetching...

{:else if publicationsQuery.isError}

Error

-{:else if publicationsQuery.isSuccess} - {@const publications = publicationsQuery.data.pages.map((p) => p.siteStandardPublication.edges.map((edge) => edge.node)).flat()} - {#each publications as publication} - {publication.uri} -

{publication.value.url}

+{:else} + {#each currentPage as publication (publication.uri)} + {publication.value.url} {/each} - {#if publicationsQuery.hasNextPage} - - {/if} {/if} diff --git a/src/routes/pub/+page.svelte b/src/routes/pub/+page.svelte deleted file mode 100644 index d873607..0000000 --- a/src/routes/pub/+page.svelte +++ /dev/null @@ -1,61 +0,0 @@ - - -{#if documentsQuery.isFetching} -

Fetching...

-{:else if documentsQuery.isError} -

Error

-{:else if documentsQuery.isSuccess} - {@const documents = documentsQuery.data} - {#if documents.length === 0} -

No documents...

- {:else} - {#each documents as document} -

{document.value.title}

- {/each} - {/if} -{/if} -