mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-24 08:19:48 +01:00
Merge branch 'master' of https://github.com/NodeBB/NodeBB
This commit is contained in:
@@ -92,5 +92,6 @@
|
||||
"follow_topics_you_reply_to": "Follow topics that you reply to.",
|
||||
"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() {
|
||||
var nid = this.getAttribute('data-nid');
|
||||
|
||||
socket.emit('notifications.markRead', nid, function(err) {
|
||||
var unread = $(this).hasClass('unread');
|
||||
if (!unread) {
|
||||
return;
|
||||
}
|
||||
socket.emit('notifications.markRead', $(this).attr('data-nid'), function(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) {
|
||||
var liEl = $(this.parentNode),
|
||||
nid = liEl.attr('data-nid'),
|
||||
var liEl = $(this).parent(),
|
||||
unread = liEl.hasClass('unread');
|
||||
|
||||
e.preventDefault();
|
||||
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) {
|
||||
app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -363,10 +363,22 @@ function sortPosts(posts, data) {
|
||||
}
|
||||
|
||||
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, []);
|
||||
}
|
||||
|
||||
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({
|
||||
watchedCids: function(next) {
|
||||
if (data.categories.indexOf('watched') !== -1) {
|
||||
|
||||
@@ -131,16 +131,39 @@ module.exports = function(User) {
|
||||
}
|
||||
|
||||
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) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var sets = uids.map(function(uid) {
|
||||
var followingSets = results.followers.map(function(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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user