v1.18.x
psychobunny 10 years ago
commit f601bdee5e

@ -92,5 +92,6 @@
"follow_topics_you_reply_to": "Follow topics that you reply to.", "follow_topics_you_reply_to": "Follow topics that you reply to.",
"follow_topics_you_create": "Follow topics you create.", "follow_topics_you_create": "Follow topics you create.",
"grouptitle": "Select the group title you would like to display" "grouptitle": "Select the group title you would like to display",
"no-group-title": "No group title"
} }

@ -39,12 +39,15 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
}); });
notifList.on('click', '[data-nid]', function() { notifList.on('click', '[data-nid]', function() {
var nid = this.getAttribute('data-nid'); var unread = $(this).hasClass('unread');
if (!unread) {
socket.emit('notifications.markRead', nid, function(err) { return;
}
socket.emit('notifications.markRead', $(this).attr('data-nid'), function(err) {
if (err) { if (err) {
app.alertError(err.message); return app.alertError(err.message);
} }
increaseNotifCount(-1);
}); });
}); });
@ -58,14 +61,13 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
}); });
notifList.on('click', '.mark-read', function(e) { notifList.on('click', '.mark-read', function(e) {
var liEl = $(this.parentNode), var liEl = $(this).parent(),
nid = liEl.attr('data-nid'),
unread = liEl.hasClass('unread'); unread = liEl.hasClass('unread');
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
socket.emit('notifications.mark' + (unread ? 'Read' : 'Unread'), nid, function(err) { socket.emit('notifications.mark' + (unread ? 'Read' : 'Unread'), liEl.attr('data-nid'), function(err) {
if (err) { if (err) {
app.alertError(err.message); app.alertError(err.message);
} }

@ -363,10 +363,22 @@ function sortPosts(posts, data) {
} }
function getSearchCids(data, callback) { function getSearchCids(data, callback) {
if (!Array.isArray(data.categories) || !data.categories.length || data.categories.indexOf('all') !== -1) { if (!Array.isArray(data.categories) || !data.categories.length) {
return callback(null, []); return callback(null, []);
} }
if (data.categories.indexOf('all') !== -1) {
async.waterfall([
function(next) {
db.getSortedSetRange('categories:cid', 0, -1, next);
},
function(cids, next) {
privileges.categories.filterCids('read', cids, data.uid, next);
}
], callback);
return;
}
async.parallel({ async.parallel({
watchedCids: function(next) { watchedCids: function(next) {
if (data.categories.indexOf('watched') !== -1) { if (data.categories.indexOf('watched') !== -1) {

@ -131,16 +131,39 @@ module.exports = function(User) {
} }
function deleteUserFromFollowers(uid, callback) { function deleteUserFromFollowers(uid, callback) {
db.getSetMembers('followers:' + uid, function(err, uids) { async.parallel({
followers: async.apply(db.getSortedSetRange, 'followers:' + uid, 0, -1),
following: async.apply(db.getSortedSetRange, 'following:' + uid, 0, -1)
}, function(err, results) {
function updateCount(uids, name, fieldName, next) {
async.each(uids, function(uid, next) {
db.sortedSetCard(name + uid, function(err, count) {
if (err) {
return next(err);
}
count = parseInt(count, 10) || 0;
db.setObjectField('user:' + uid, fieldName, count, next);
});
}, next);
}
if (err) { if (err) {
return callback(err); return callback(err);
} }
var sets = uids.map(function(uid) { var followingSets = results.followers.map(function(uid) {
return 'following:' + uid; return 'following:' + uid;
}); });
db.setsRemove(sets, uid, callback); var followerSets = results.following.map(function(uid) {
return 'followers:' + uid;
});
async.parallel([
async.apply(db.sortedSetsRemove, followerSets.concat(followingSets), uid),
async.apply(updateCount, results.following, 'followers:', 'followerCount'),
async.apply(updateCount, results.followers, 'following:', 'followingCount')
], callback);
}); });
} }
}; };

Loading…
Cancel
Save