Fix incorrect order causing wrong timeline Link headers

This commit is contained in:
Jesse Wierzbinski 2024-04-07 16:36:14 -10:00
parent d3a625e084
commit 5812618170
No known key found for this signature in database

View file

@ -17,11 +17,12 @@ export async function fetchTimeline<T extends User | Status>(
// Check if there are statuses before the first one // Check if there are statuses before the first one
// @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 objectsBefore = await model.findMany({ const objectsBefore = await model.findMany({
...args,
where: { where: {
...args.where,
id: { id: {
gt: objects[0].id, gt: objects[0].id,
}, },
...args.where,
}, },
take: 1, take: 1,
}); });
@ -38,11 +39,12 @@ export async function fetchTimeline<T extends User | Status>(
// Check if there are statuses after the last one // Check if there are statuses after the last one
// @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 objectsAfter = await model.findMany({ const objectsAfter = await model.findMany({
...args,
where: { where: {
...args.where,
id: { id: {
lt: objects.at(-1)?.id, lt: objects.at(-1)?.id,
}, },
...args.where,
}, },
take: 1, take: 1,
}); });