From 6765de3db3f58a4203d568e6369c969789eeccd2 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 6 May 2020 15:42:45 -0400 Subject: [PATCH] fix: sortable topics even if only 1 pinned topic --- public/src/client/category/tools.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.js index 3e973c68a3..f219a399af 100644 --- a/public/src/client/category/tools.js +++ b/public/src/client/category/tools.js @@ -254,9 +254,15 @@ define('forum/category/tools', [ } function handlePinnedTopicSort() { - if (!ajaxify.data.privileges.isAdminOrMod) { + var numPinned = ajaxify.data.topics.reduce(function (memo, topic) { + memo = topic.pinned ? memo += 1 : memo; + return memo; + }, 0); + + if (!ajaxify.data.privileges.isAdminOrMod || numPinned < 2) { return; } + app.loadJQueryUI(function () { var topicListEl = $('[component="category"]').filter(function (i, e) { return !$(e).parents('[widget-area],[data-widget-area]').length;