From d500ebb181b1d24b9e1e74f2495555de5431c8d0 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 17 Jan 2024 23:11:16 -0500 Subject: [PATCH] fix: bookmark in topic data is nullable now This prevents the superfluous "/1" being appended to all topics you've never been into. This looks to be a change in the public API but the documented API lists this property as nullable already, so it looks like this commit is actually *restoring* proper behaviour. --- src/topics/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/topics/index.js b/src/topics/index.js index d5e997d4c0..3d313d08e6 100644 --- a/src/topics/index.js +++ b/src/topics/index.js @@ -138,9 +138,9 @@ Topics.getTopicsByTids = async function (tids, options) { topic.isOwner = topic.uid === parseInt(uid, 10); topic.ignored = isIgnored[i]; topic.unread = parseInt(uid, 10) <= 0 || (!hasRead[i] && !isIgnored[i]); - topic.bookmark = sortNewToOld ? + topic.bookmark = bookmarks[i] && (sortNewToOld ? Math.max(1, topic.postcount + 2 - bookmarks[i]) : - Math.min(topic.postcount, bookmarks[i] + 1); + Math.min(topic.postcount, bookmarks[i] + 1)); topic.unreplied = !topic.teaser; topic.icons = [];