This commit is contained in:
barisusakli
2015-10-19 12:48:26 -04:00
parent d61ac000a8
commit f17ba88c0f
4 changed files with 52 additions and 9 deletions

View File

@@ -21,7 +21,7 @@ var async = require('async'),
if (!parseInt(uid, 10)) {
return callback(null , {read: [], unread: []});
}
getNotifications(uid, 10, function(err, notifications) {
getNotifications(uid, 0, 9, function(err, notifications) {
if (err) {
return callback(err);
}
@@ -38,8 +38,8 @@ var async = require('async'),
});
};
UserNotifications.getAll = function(uid, count, callback) {
getNotifications(uid, count, function(err, notifs) {
UserNotifications.getAll = function(uid, start, stop, callback) {
getNotifications(uid, start, stop, function(err, notifs) {
if (err) {
return callback(err);
}
@@ -52,13 +52,13 @@ var async = require('async'),
});
};
function getNotifications(uid, count, callback) {
function getNotifications(uid, start, stop, callback) {
async.parallel({
unread: function(next) {
getNotificationsFromSet('uid:' + uid + ':notifications:unread', false, uid, 0, count - 1, next);
getNotificationsFromSet('uid:' + uid + ':notifications:unread', false, uid, start, stop, next);
},
read: function(next) {
getNotificationsFromSet('uid:' + uid + ':notifications:read', true, uid, 0, count - 1, next);
getNotificationsFromSet('uid:' + uid + ':notifications:read', true, uid, start, stop, next);
}
}, callback);
}