mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
[mastodon-client] Fix link pagination prev attribute when minId is set
This commit is contained in:
parent
3204bd9d18
commit
fef807a165
6 changed files with 15 additions and 15 deletions
|
@ -58,7 +58,7 @@ export class ListHelpers {
|
|||
.map(p => p.user)
|
||||
.filter(p => p) as User[];
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ export class NoteHelpers {
|
|||
.map(p => p.user)
|
||||
.filter(p => p) as User[];
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ export class NoteHelpers {
|
|||
.map(p => p.user)
|
||||
.filter(p => p) as User[];
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ export class PaginationHelpers {
|
|||
const ids = p.map(x => x.id);
|
||||
ctx.pagination = p.length > 0 ? {
|
||||
limit: limit,
|
||||
maxId: ids.at(reverse ? 0 : -1),
|
||||
minId: ids.at(reverse ? -1 : 0)
|
||||
maxId: ids.at(-1),
|
||||
minId: ids.at(0)
|
||||
} : undefined;
|
||||
return p;
|
||||
});
|
||||
|
|
|
@ -216,7 +216,7 @@ export class TimelineHelpers {
|
|||
}
|
||||
});
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.threadId ?? p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.threadId ?? p.id), limit);
|
||||
return Promise.all(conversations.map(c => awaitAll(c)));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ export class UserHelpers {
|
|||
} as MastodonEntity.MutedAccount
|
||||
}));
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ export class UserHelpers {
|
|||
.map(p => p.blockee)
|
||||
.filter(p => p) as User[];
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ export class UserHelpers {
|
|||
.map(p => p.follower)
|
||||
.filter(p => p) as User[];
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ export class UserHelpers {
|
|||
|
||||
return PaginationHelpers.execQuery(query, limit, minId !== undefined)
|
||||
.then(res => {
|
||||
ctx.pagination = generatePaginationData(res.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(res.map(p => p.id), limit);
|
||||
return res.map(p => p.note as Note);
|
||||
});
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ export class UserHelpers {
|
|||
|
||||
return PaginationHelpers.execQuery(query, limit, minId !== undefined)
|
||||
.then(res => {
|
||||
ctx.pagination = generatePaginationData(res.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(res.map(p => p.id), limit);
|
||||
return res.map(p => p.note as Note);
|
||||
});
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ export class UserHelpers {
|
|||
return query.take(limit).getMany().then(p => {
|
||||
if (minId !== undefined) p = p.reverse();
|
||||
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit, minId !== undefined);
|
||||
ctx.pagination = generatePaginationData(p.map(p => p.id), limit);
|
||||
return p.map(p => type === "followers" ? p.follower : p.followee).filter(p => p) as User[];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ export async function PaginationMiddleware(ctx: MastoContext, next: () => Promis
|
|||
}
|
||||
}
|
||||
|
||||
export function generatePaginationData(ids: string[], limit: number, reverse: boolean): PaginationData | undefined {
|
||||
export function generatePaginationData(ids: string[], limit: number): PaginationData | undefined {
|
||||
if (ids.length < 1) return undefined;
|
||||
|
||||
return {
|
||||
limit: limit,
|
||||
maxId: ids.at(reverse ? 0 : -1),
|
||||
minId: ids.at(reverse ? -1 : 0)
|
||||
maxId: ids.at(-1),
|
||||
minId: ids.at(0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue