Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/site/app/channel/[id]/[index]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default async function ItemPage({
}) {
const { channel } = await getChannelWithId({
id: params.id,
limit: 100,
})

const totalItems = channel?.adds?.items?.length ?? 0
Expand Down
13 changes: 11 additions & 2 deletions apps/site/app/channel/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewToggle } from '@/client'
import { ViewToggle, PaginationControls } from '@/client'
import { Flex, Stack, Typography } from '@/design-system'
import { getChannelWithId } from '@/gql'
import { getAddsMetadata } from '@/lib'
Expand All @@ -17,8 +17,13 @@ export default async function Channel({
params: { id: string }
searchParams: { [key: string]: string | string[] | undefined }
}) {
const { channel } = await getChannelWithId({
// biome-ignore lint:
const after = searchParams['after'] as string | undefined

const { channel, pageInfo } = await getChannelWithId({
id: params.id,
limit: 100,
after,
})

if (!channel) {
Expand Down Expand Up @@ -58,6 +63,10 @@ export default async function Channel({
</div>
<div className="hidden md:w-[3%] md:block">{}</div>
</Flex>
<Flex className="pt-32 pb-8 justify-center">
{/* @ts-ignore */}
<PaginationControls pageInfo={pageInfo} />
</Flex>
</section>
)
}
7 changes: 5 additions & 2 deletions apps/site/gql/queries/channelWithId.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query channelWithId($id: String!) {
query channelWithId($id: String!, $limit: Int!, $after: String) {
channel(id: $id) {
id
timestamp
Expand All @@ -13,7 +13,7 @@ query channelWithId($id: String!) {
role
}
}
adds(limit: 100, orderBy: "timestamp", orderDirection: "desc") {
adds(limit: $limit, orderBy: "timestamp", orderDirection: "desc", after: $after) {
items {
timestamp
channelId
Expand All @@ -35,6 +35,9 @@ query channelWithId($id: String!) {
}
}
}
pageInfo {
...PageInfo
}
}
}
}
15 changes: 12 additions & 3 deletions apps/site/gql/requests/getChannelWithId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ import sdk from '../client'
import { unstable_cache } from 'next/cache'

export const getChannelWithId = unstable_cache(
async ({ id }: { id: string }) => {
async ({
id,
limit,
after,
}: { id: string; limit: number; after?: string }) => {
const response = await sdk.channelWithId({
id: id,
id,
limit,
after,
})

return { channel: response.channel }
return {
channel: response.channel,
pageInfo: response.channel?.adds?.pageInfo,
}
},
['channelWithId'],
)
Loading