Skip to content

Commit

Permalink
fix: dont show delete topics on unread
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Oct 30, 2019
1 parent 7655265 commit b91c479
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/topics/unread.js
Expand Up @@ -123,7 +123,7 @@ module.exports = function (Topics) {
});

tids = await privileges.topics.filterTids('topics:read', tids, params.uid);
const topicData = await Topics.getTopicsFields(tids, ['tid', 'cid', 'uid', 'postcount']);
const topicData = (await Topics.getTopicsFields(tids, ['tid', 'cid', 'uid', 'postcount', 'deleted'])).filter(t => !t.deleted);
const topicCids = _.uniq(topicData.map(topic => topic.cid)).filter(Boolean);

const categoryWatchState = await categories.getWatchState(topicCids, params.uid);
Expand Down Expand Up @@ -258,11 +258,12 @@ module.exports = function (Topics) {
return false;
}
const [topicScores, userScores] = await Promise.all([
db.sortedSetScores('topics:recent', tids),
Topics.getTopicsFields(tids, ['tid', 'lastposttime']),
db.sortedSetScores('uid:' + uid + ':tids_read', tids),
]);

tids = tids.filter((tid, index) => topicScores[index] && (!userScores[index] || userScores[index] < topicScores[index]));
tids = topicScores.filter((t, i) => t.lastposttime && (!userScores[i] || userScores[i] < t.lastposttime))
.map(t => t.tid);

if (!tids.length) {
return false;
Expand Down

0 comments on commit b91c479

Please sign in to comment.