mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
11
src/user.js
11
src/user.js
@@ -757,7 +757,7 @@ var utils = require('./../public/src/utils.js'),
|
||||
get: function(uid, callback) {
|
||||
async.parallel({
|
||||
unread: function(next) {
|
||||
RDB.zrangebyscore('uid:' + uid + ':notifications:unread', 0, 10, function(err, nids) {
|
||||
RDB.zrevrangebyscore('uid:' + uid + ':notifications:unread', 10, 0, function(err, nids) {
|
||||
var unread = [];
|
||||
if (nids && nids.length > 0) {
|
||||
async.eachSeries(nids, function(nid, next) {
|
||||
@@ -772,7 +772,7 @@ var utils = require('./../public/src/utils.js'),
|
||||
});
|
||||
},
|
||||
read: function(next) {
|
||||
RDB.zrangebyscore('uid:' + uid + ':notifications:read', 0, 10, function(err, nids) {
|
||||
RDB.zrevrangebyscore('uid:' + uid + ':notifications:read', 10, 0, function(err, nids) {
|
||||
var read = [];
|
||||
if (nids && nids.length > 0) {
|
||||
async.eachSeries(nids, function(nid, next) {
|
||||
@@ -787,6 +787,13 @@ var utils = require('./../public/src/utils.js'),
|
||||
});
|
||||
}
|
||||
}, function(err, notifications) {
|
||||
// While maintaining score sorting, sort by time
|
||||
notifications.read.sort(function(a, b) {
|
||||
if (a.score === b.score) return (a.datetime - b.datetime) > 0 ? -1 : 1;
|
||||
});
|
||||
notifications.unread.sort(function(a, b) {
|
||||
if (a.score === b.score) return (a.datetime - b.datetime) > 0 ? -1 : 1;
|
||||
});
|
||||
callback(notifications);
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user