update counter when user navigates to /unread
fix new topic alert on /unread
moved unread code from footer to unread
This commit is contained in:
Barış Soner Uşaklı
2018-12-12 19:43:35 -05:00
parent 2f57a4b9a6
commit f103390aa5
6 changed files with 98 additions and 97 deletions

View File

@@ -215,26 +215,26 @@ module.exports = function (Topics) {
if (topic && topic.cid && cidMatch(topic.cid) && !blockedUids.includes(parseInt(topic.uid, 10))) {
topic.tid = parseInt(topic.tid, 10);
if ((results.isTopicsFollowed[index] || !isCidIgnored[topic.cid])) {
counts[''] += 1;
tidsByFilter[''].push(topic.tid);
}
if (results.isTopicsFollowed[index]) {
counts.watched += 1;
tidsByFilter.watched.push(topic.tid);
}
if (topic.postcount <= 1) {
counts.unreplied += 1;
tidsByFilter.unreplied.push(topic.tid);
}
if (!userRead[topic.tid]) {
counts.new += 1;
tidsByFilter.new.push(topic.tid);
}
}
});
counts[''] = tidsByFilter[''].length;
counts.watched = tidsByFilter.watched.length;
counts.unreplied = tidsByFilter.unreplied.length;
counts.new = tidsByFilter.new.length;
next(null, {
counts: counts,
@@ -439,10 +439,8 @@ module.exports = function (Topics) {
};
Topics.hasReadTopics = function (tids, uid, callback) {
if (!parseInt(uid, 10)) {
return callback(null, tids.map(function () {
return false;
}));
if (!(parseInt(uid, 10) > 0)) {
return setImmediate(callback, null, tids.map(() => false));
}
async.waterfall([