mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
Fix pagination bug
This commit is contained in:
parent
e0335c33a9
commit
d3a625e084
|
|
@ -5,6 +5,8 @@ export async function fetchTimeline<T extends User | Status>(
|
||||||
args: Prisma.StatusFindManyArgs | Prisma.UserFindManyArgs,
|
args: Prisma.StatusFindManyArgs | Prisma.UserFindManyArgs,
|
||||||
req: Request,
|
req: Request,
|
||||||
) {
|
) {
|
||||||
|
// BEFORE: Before in a top-to-bottom order, so the most recent posts
|
||||||
|
// AFTER: After in a top-to-bottom order, so the oldest posts
|
||||||
// @ts-expect-error This is a hack to get around the fact that Prisma doesn't have a common base type for all models
|
// @ts-expect-error This is a hack to get around the fact that Prisma doesn't have a common base type for all models
|
||||||
const objects = (await model.findMany(args)) as T[];
|
const objects = (await model.findMany(args)) as T[];
|
||||||
|
|
||||||
|
|
@ -49,9 +51,7 @@ export async function fetchTimeline<T extends User | Status>(
|
||||||
const urlWithoutQuery = req.url.split("?")[0];
|
const urlWithoutQuery = req.url.split("?")[0];
|
||||||
// Add next link
|
// Add next link
|
||||||
linkHeader.push(
|
linkHeader.push(
|
||||||
`<${urlWithoutQuery}?max_id=${
|
`<${urlWithoutQuery}?max_id=${objectsAfter[0].id}>; rel="next"`,
|
||||||
objects.at(-1)?.id
|
|
||||||
}>; rel="next"`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue