updated topic viewing so that markAsRead marks any relevant notifications read (issue #219)

v1.18.x
Julian Lam 12 years ago
parent f1144f3a7e
commit 1df50ff855

@ -7,6 +7,7 @@ var RDB = require('./redis.js')
posts = require('./posts.js'),
threadTools = require('./threadTools.js'),
postTools = require('./postTools'),
Notifications = require('./notifications'),
async = require('async'),
feed = require('./feed.js'),
favourites = require('./favourites.js'),
@ -511,6 +512,14 @@ var RDB = require('./redis.js')
}
});
});
user.notifications.getUnreadByUniqueId(uid, 'topic:' + tid, function(err, nids) {
if (nids.length > 0) {
async.each(nids, function(nid, next) {
Notifications.mark_read(nid, uid, next);
});
}
});
}
Topics.hasReadTopics = function(tids, uid, callback) {

@ -985,6 +985,18 @@ var utils = require('./../public/src/utils.js'),
},
getUnreadCount: function(uid, callback) {
RDB.zcount('uid:' + uid + ':notifications:unread', 0, 10, callback);
},
getUnreadByUniqueId: function(uid, uniqueId, callback) {
RDB.zrange('uid:' + uid + ':notifications:unread', 0, -1, function(err, nids) {
async.filter(nids, function(nid, next) {
notifications.get(nid, function(notifObj) {
if (notifObj.uniqueId === uniqueId) next(true);
else next(false);
});
}, function(nids) {
callback(null, nids);
});
});
}
}
}(exports));

Loading…
Cancel
Save