refactor: remove breaking change in pin expiry

This commit is contained in:
Barış Soner Uşaklı
2020-11-20 14:05:02 -05:00
parent 046d0b1637
commit ef3df47a6d
2 changed files with 7 additions and 16 deletions

View File

@@ -57,21 +57,18 @@ module.exports = function (Topics) {
async function getCidTids(params) {
const sets = [];
const pinnedSets = [];
params.cids.forEach(function (cid) {
if (params.sort === 'recent') {
sets.push('cid:' + cid + ':tids');
} else {
sets.push('cid:' + cid + ':tids' + (params.sort ? ':' + params.sort : ''));
}
pinnedSets.push('cid:' + cid + ':tids:pinned');
});
const [tids, pinnedTids] = await Promise.all([
db.getSortedSetRevRange(sets, 0, meta.config.recentMaxTopics - 1),
categories.getPinnedTids({
cid: params.cids,
start: 0,
stop: -1,
}),
]);
let pinnedTids = await db.getSortedSetRevRange(pinnedSets, 0, -1);
pinnedTids = await Topics.tools.checkPinExpiry(pinnedTids);
const tids = await db.getSortedSetRevRange(sets, 0, meta.config.recentMaxTopics - 1);
return pinnedTids.concat(tids);
}