From 9ee1d7b063f8e7eee2d0a1636f8db7f32b005fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 16 Jun 2023 09:05:37 -0400 Subject: [PATCH] fix: if reply is in different topic dont hide in parent --- src/topics/posts.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/topics/posts.js b/src/topics/posts.js index 06b9c28635..58ad3d20c9 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -342,7 +342,7 @@ module.exports = function (Topics) { const postDataMap = _.zipObject(pids, postData); const returnData = await Promise.all(arrayOfReplyPids.map(async (replyPids, idx) => { - const currentPid = pids[idx]; + const currentPost = postData[idx]; replyPids = replyPids.filter(pid => pidMap[pid]); const uidsUsed = {}; const currentData = { @@ -370,7 +370,7 @@ module.exports = function (Topics) { } if (replyPids.length === 1) { - const currentIndex = postDataMap[currentPid] ? postDataMap[currentPid].index : null; + const currentIndex = currentPost ? currentPost.index : null; const replyPid = replyPids[0]; // only load index of nested reply if we can't find it in the postDataMap let replyPost = postDataMap[replyPid]; @@ -378,9 +378,12 @@ module.exports = function (Topics) { const tid = await posts.getPostField(replyPid, 'tid'); replyPost = { index: await posts.getPidIndex(replyPid, tid, userSettings.topicPostSort), + tid: tid, }; } - currentData.hasSingleImmediateReply = Math.abs(currentIndex - replyPost.index) === 1; + currentData.hasSingleImmediateReply = + (currentPost && currentPost.tid === replyPost.tid) && + Math.abs(currentIndex - replyPost.index) === 1; } return currentData;