fix: #12502, improper decrement

This commit is contained in:
Julian Lam
2024-04-12 14:46:15 -04:00
parent 64258dac19
commit 6befff5e11

View File

@@ -316,7 +316,7 @@ Topics.search = async function (tid, term) {
Topics.getPidByIndex = async function (tid, index) {
index -= 2; // zset only stores replies, index is not zero-indexed, so offset by 2.
return index > 0 ?
(await db.getSortedSetRange(`tid:${tid}:posts`, index - 2, index - 2)).pop() :
(await db.getSortedSetRange(`tid:${tid}:posts`, index, index)).pop() :
await Topics.getTopicField(tid, 'mainPid');
};