Skip to content

Node.js based forum software built for the modern web

removed unused .getAll method, and sorting notifications client-side so that unread notifs don't all appear at the top, #2772

Julian Lam29873f1c5c55
diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js
index 6e36cf7296..d0f92d0230 100644
--- a/public/src/modules/notifications.js
+++ b/public/src/modules/notifications.js
@@ -22,7 +22,9 @@ define('notifications', ['sounds'], function(sound) {
return app.alertError(err.message);
}
- var notifs = data.unread.concat(data.read);
+ var notifs = data.unread.concat(data.read).sort(function(a, b) {
+ return parseInt(a.datetime, 10) > parseInt(b.datetime, 10) ? -1 : 1;
+ });
translator.toggleTimeagoShorthand();
for(var i=0; i<notifs.length; ++i) {
diff --git a/src/user/notifications.js b/src/user/notifications.js
index 706c227097..3a11b06a0a 100644
--- a/src/user/notifications.js
+++ b/src/user/notifications.js
@@ -89,20 +89,6 @@ var async = require('async'),
});
}
- UserNotifications.getAll = function(uid, count, callback) {
- getNotifications(uid, count, function(err, notifs) {
- if (err) {
- return callback(err);
- }
- notifs = notifs.unread.concat(notifs.read);
- notifs = notifs.filter(Boolean).sort(function(a, b) {
- return b.datetime - a.datetime;
- });
-
- callback(null, notifs);
- });
- };
-
UserNotifications.getNotifications = function(nids, uid, callback) {
notifications.getMultiple(nids, function(err, notifications) {
if (err) {