From 3ecac97d7e454b97124bc804ae36fd1fb356d094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 8 Aug 2019 12:11:13 -0400 Subject: [PATCH] fix: #7826, fix order of categories on recent dropdown --- src/controllers/helpers.js | 2 +- src/user/categories.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 394644d7b2..10e9e6dd00 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -273,7 +273,7 @@ function getCategoryData(cids, uid, selectedCid, callback) { } async.waterfall([ function (next) { - categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'link', 'color', 'bgColor', 'parentCid', 'image', 'imageClass'], next); + categories.getCategoriesFields(cids, ['cid', 'order', 'name', 'slug', 'icon', 'link', 'color', 'bgColor', 'parentCid', 'image', 'imageClass'], next); }, function (categoryData, next) { categoryData = categoryData.filter(category => category && !category.link); diff --git a/src/user/categories.js b/src/user/categories.js index 0978eb9da5..74a6b4ed7d 100644 --- a/src/user/categories.js +++ b/src/user/categories.js @@ -49,9 +49,9 @@ module.exports = function (User) { if (!(parseInt(uid, 10) > 0)) { return await categories.getAllCidsFromSet('categories:cid'); } - const userState = await User.getCategoryWatchState(uid); - const cids = Object.keys(userState); - return cids.filter(cid => states.includes(userState[cid])); + const cids = await categories.getAllCidsFromSet('categories:cid'); + const userState = await categories.getWatchState(cids, uid); + return cids.filter((cid, index) => states.includes(userState[index])); }; User.ignoreCategory = async function (uid, cid) {