mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[mastodon-client] Don't return 'next' link pagination header when there are not more results
This fixes clients like toot! showing ghost users
This commit is contained in:
parent
53bb79706e
commit
73895e856c
@ -1,5 +1,6 @@
|
||||
import { ObjectLiteral, SelectQueryBuilder } from "typeorm";
|
||||
import { MastoContext } from "@/server/api/mastodon/index.js";
|
||||
import { generatePaginationData } from "@/server/api/mastodon/middleware/pagination.js";
|
||||
|
||||
export class PaginationHelpers {
|
||||
public static makePaginationQuery<T extends ObjectLiteral>(
|
||||
@ -48,12 +49,7 @@ export class PaginationHelpers {
|
||||
public static async execQueryLinkPagination<T extends ObjectLiteral>(query: SelectQueryBuilder<T>, limit: number, reverse: boolean, ctx: MastoContext): Promise<T[]> {
|
||||
return this.execQuery(query, limit, reverse)
|
||||
.then(p => {
|
||||
const ids = p.map(x => x.id);
|
||||
ctx.pagination = p.length > 0 ? {
|
||||
limit: limit,
|
||||
maxId: ids.at(-1),
|
||||
minId: ids.at(0)
|
||||
} : undefined;
|
||||
ctx.pagination = generatePaginationData(p.map(x => x.id), limit);
|
||||
return p;
|
||||
});
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export function generatePaginationData(ids: string[], limit: number): Pagination
|
||||
|
||||
return {
|
||||
limit: limit,
|
||||
maxId: ids.at(-1),
|
||||
maxId: ids.length < limit ? undefined : ids.at(-1),
|
||||
minId: ids.at(0)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user