Skip to content

Commit

Permalink
Merge pull request #478 from whtsupbab3/475-repeating-bounty-claims-l…
Browse files Browse the repository at this point in the history
…oading

fix: issue #475
  • Loading branch information
picsoritdidnthappen authored Jan 17, 2025
2 parents 69a4e6c + a873845 commit c264121
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/trpc/routers/_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ export const appRouter = createTRPCRouter({
bountyId: z.number(),
chainId: z.number(),
limit: z.number().min(1).max(100).default(10),
cursor: z.number().nullish(),
cursor: z
.object({
id: z.number(),
ids: z.array(z.number()),
})
.nullish(),
})
)
.query(async ({ input }) => {
Expand All @@ -221,7 +226,8 @@ export const appRouter = createTRPCRouter({
ban: {
none: {},
},
...(input.cursor ? { id: { lt: input.cursor } } : {}),
...(input.cursor ? { id: { lt: input.cursor.id } } : {}),
...(input.cursor && { id: { notIn: input.cursor.ids } }),
},
orderBy: [{ is_accepted: 'desc' }, { id: 'desc' }],
take: input.limit,
Expand All @@ -236,9 +242,17 @@ export const appRouter = createTRPCRouter({
},
});

let nextCursor: (typeof items)[number]['id'] | undefined = undefined;
let nextCursor:
| {
id: (typeof items)[number]['id'];
ids: (typeof items)[number]['id'][];
}
| undefined = undefined;
if (items.length === input.limit) {
nextCursor = items[items.length - 1].id;
nextCursor = {
id: items[items.length - 1].id,
ids: [...(input.cursor?.ids ?? []), ...items.map((item) => item.id)],
};
}

return {
Expand Down

0 comments on commit c264121

Please sign in to comment.