fix: #7826, fix order of categories on recent dropdown

v1.18.x
Barış Soner Uşaklı 6 years ago
parent cbede89af3
commit 3ecac97d7e

@ -273,7 +273,7 @@ function getCategoryData(cids, uid, selectedCid, callback) {
} }
async.waterfall([ async.waterfall([
function (next) { 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) { function (categoryData, next) {
categoryData = categoryData.filter(category => category && !category.link); categoryData = categoryData.filter(category => category && !category.link);

@ -49,9 +49,9 @@ module.exports = function (User) {
if (!(parseInt(uid, 10) > 0)) { if (!(parseInt(uid, 10) > 0)) {
return await categories.getAllCidsFromSet('categories:cid'); return await categories.getAllCidsFromSet('categories:cid');
} }
const userState = await User.getCategoryWatchState(uid); const cids = await categories.getAllCidsFromSet('categories:cid');
const cids = Object.keys(userState); const userState = await categories.getWatchState(cids, uid);
return cids.filter(cid => states.includes(userState[cid])); return cids.filter((cid, index) => states.includes(userState[index]));
}; };
User.ignoreCategory = async function (uid, cid) { User.ignoreCategory = async function (uid, cid) {

Loading…
Cancel
Save