Skip to content

Commit bd8044e

Browse files
wxh06immccn123
authored andcommitted
依据 id 而非时间判断最新回复是否改变
1 parent 2ccc2ee commit bd8044e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/archive/src/lib/list.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async function getPostList(
5353
await prisma.post.findMany({
5454
select: {
5555
id: true,
56-
replies: { select: { time: true }, orderBy: { id: "desc" }, take: 1 },
56+
replies: { select: { id: true }, orderBy: { id: "desc" }, take: 1 },
5757
},
5858
where: {
5959
id: {
@@ -63,17 +63,16 @@ export default async function getPostList(
6363
},
6464
},
6565
})
66-
).map(({ id, replies }) => [id, replies[0]?.time]),
66+
).map(({ id, replies }) => [id, replies[0]?.id as number | undefined]),
6767
);
6868
return result
6969
.filter(
7070
(post) =>
71-
post.time >= after ||
72-
!(post.id in saved) ||
73-
(post.recentReply &&
74-
(!saved[post.id] ||
75-
Math.floor(saved[post.id].getTime() / 60000) !==
76-
Math.floor(post.recentReply.time / 60))),
71+
post.time >= after || // 晚于特定时间则一定尝试保存
72+
!(post.id in saved) || // 没有保存过亦如此
73+
(post.recentReply && // 有回复并
74+
(!saved[post.id] || // 上一次保存时没有回复或
75+
saved[post.id] !== post.recentReply.id)), // 最新回复 id 不一致
7776
)
7877
.map((post) => post.id);
7978
}

0 commit comments

Comments
 (0)