fix pagination for shuffled timeline
Some checks failed
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/test Pipeline failed

This commit is contained in:
Johann150 2023-10-30 17:41:44 +01:00
parent f4e234d108
commit 6367fcca79
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 9 additions and 5 deletions

View file

@ -32,8 +32,7 @@ export const paramDef = {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
offset: { type: 'integer', minimum: 0, default: 0 },
seed: {
description: 'A seed for the shuffling. If the same seed is provided, the same shuffling will be used. Required for pagination to work.',
type: 'number',
@ -45,8 +44,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
//#region Construct query
const query = makePaginationQuery(Notes.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
const query = Notes.createQueryBuilder('note')
.addSelect('md5(note.id || ' + ps.seed + ')', 'shuffleorder')
.andWhere('note.userId = :meId', { meId: user.id })
.innerJoinAndSelect('note.user', 'user')
@ -70,7 +68,10 @@ export default define(meta, paramDef, async (ps, user) => {
generateMutedRenotesQuery(query, user);
//#endregion
const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
const timeline = await visibilityQuery(query, user)
.skip(ps.offset)
.take(ps.limit)
.getMany();
process.nextTick(() => {
activeUsersChart.read(user);

View file

@ -54,6 +54,7 @@ const onChangeFollowing = () => {
let randomSeed = Math.random();
let endpoint;
let query;
let offsetMode = false;
let connection;
let connection2;
@ -142,6 +143,7 @@ switch (props.src) {
query = {
seed: randomSeed,
};
offsetMode = true;
break;
}
@ -149,6 +151,7 @@ const pagination = {
endpoint,
limit: 10,
params: query,
offsetMode,
};
onUnmounted(() => {