Skip to content

Node.js based forum software built for the modern web

fix: 'unread' postIndex regression closes #10607

Barış Soner Uşaklı0e60a704a5c2
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index bc7259cb90..807e546a00 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -58,12 +58,12 @@ topicsController.get = async function getTopic(req, res, next) {
return helpers.notAllowed(req, res);
}
- if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}/`)) {
- return helpers.redirect(res, `/topic/${topicData.slug}${postIndex ? `/${postIndex}` : ''}${generateQueryString(req.query)}`, true);
+ if (req.params.post_index === 'unread') {
+ postIndex = await topics.getUserBookmark(tid, req.uid);
}
- if (postIndex === 'unread') {
- postIndex = await topics.getUserBookmark(tid, req.uid);
+ if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}/`)) {
+ return helpers.redirect(res, `/topic/${topicData.slug}${postIndex ? `/${postIndex}` : ''}${generateQueryString(req.query)}`, true);
}
if (utils.isNumber(postIndex) && topicData.postcount > 0 && (postIndex < 1 || postIndex > topicData.postcount)) {