Notifications.loadNotifications()

v1.18.x
psychobunny 10 years ago
parent 2301362f59
commit a44f467ebc

@ -17,25 +17,7 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
return;
}
socket.emit('notifications.get', null, function(err, data) {
if (err) {
return app.alertError(err.message);
}
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) {
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
}
translator.toggleTimeagoShorthand();
templates.parse('partials/notifications_list', {notifications: notifs}, function(html) {
notifList.translateHtml(html);
});
});
Notifications.loadNotifications();
});
notifList.on('click', '[data-nid]', function() {
@ -114,6 +96,28 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
});
};
Notifications.loadNotifications = function(notifList) {
socket.emit('notifications.get', null, function(err, data) {
if (err) {
return app.alertError(err.message);
}
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) {
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
}
translator.toggleTimeagoShorthand();
templates.parse('partials/notifications_list', {notifications: notifs}, function(html) {
notifList.translateHtml(html);
});
});
};
Notifications.updateNotifCount = function(count) {
var notifIcon = $('.notification-icon');

Loading…
Cancel
Save