fix: 🐛 antenna notes pagination repeat
This commit is contained in:
parent
2f49c8734d
commit
c0eac56355
@ -60,13 +60,14 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||||||
throw new ApiError(meta.errors.noSuchAntenna);
|
throw new ApiError(meta.errors.noSuchAntenna);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const limit = ps.limit + (ps.untilId ? 1 : 0) + (ps.sinceId ? 1 : 0); // untilIdに指定したものも含まれるため+1
|
||||||
const noteIdsRes = await redisClient.xrevrange(
|
const noteIdsRes = await redisClient.xrevrange(
|
||||||
`antennaTimeline:${antenna.id}`,
|
`antennaTimeline:${antenna.id}`,
|
||||||
ps.untilDate || "+",
|
ps.untilDate ?? "+",
|
||||||
"-",
|
ps.sinceDate ?? "-",
|
||||||
"COUNT",
|
"COUNT",
|
||||||
ps.limit + 1,
|
limit,
|
||||||
); // untilIdに指定したものも含まれるため+1
|
);
|
||||||
|
|
||||||
if (noteIdsRes.length === 0) {
|
if (noteIdsRes.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
@ -74,7 +75,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||||||
|
|
||||||
const noteIds = noteIdsRes
|
const noteIds = noteIdsRes
|
||||||
.map((x) => x[1][1])
|
.map((x) => x[1][1])
|
||||||
.filter((x) => x !== ps.untilId);
|
.filter((x) => x !== ps.untilId && x !== ps.sinceId);
|
||||||
|
|
||||||
if (noteIds.length === 0) {
|
if (noteIds.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
@ -105,7 +106,8 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||||||
generateMutedUserQuery(query, user);
|
generateMutedUserQuery(query, user);
|
||||||
generateBlockedUserQuery(query, user);
|
generateBlockedUserQuery(query, user);
|
||||||
|
|
||||||
const notes = await query.take(ps.limit).getMany();
|
const notes = await query.getMany();
|
||||||
|
notes.sort((a, b) => (a.id > b.id ? -1 : 1));
|
||||||
|
|
||||||
if (notes.length > 0) {
|
if (notes.length > 0) {
|
||||||
readNote(user.id, notes);
|
readNote(user.id, notes);
|
||||||
|
Loading…
Reference in New Issue
Block a user