Node.js based forum software built for the modern web
Notifications.loadNotifications()
psychobunnya44f467ebcd1
diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.jsindex bf4313b066..5ffbb1de93 100644--- a/public/src/modules/notifications.js+++ b/public/src/modules/notifications.js@@ -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');