Notification paths are now sent back in socket call, so client-

side alert now shows more data and is clickable.
v1.18.x
Julian Lam 9 years ago
parent ff86369fca
commit 5de0e74908

@ -65,13 +65,30 @@ define('notifications', ['sounds', 'translator', 'components'], function(sound,
} }
socket.on('event:new_notification', function(notifData) { socket.on('event:new_notification', function(notifData) {
app.alert({ // If a path is defined, show notif data, otherwise show generic data
var payload;
if (notifData.path) {
payload = {
alert_id: 'new_notif',
title: '[[notifications:new_notification]]',
message: notifData.bodyShort,
type: 'info',
timeout: 2000,
clickfn: function() {
ajaxify.go(notifData.path);
}
};
} else {
payload = {
alert_id: 'new_notif', alert_id: 'new_notif',
title: '[[notifications:new_notification]]', title: '[[notifications:new_notification]]',
message: '[[notifications:you_have_unread_notifications]]', message: '[[notifications:you_have_unread_notifications]]',
type: 'warning', type: 'warning',
timeout: 2000 timeout: 2000
}); };
}
app.alert(payload);
app.refreshTitle(); app.refreshTitle();
if (ajaxify.currentPage === 'notifications') { if (ajaxify.currentPage === 'notifications') {

@ -195,9 +195,12 @@ var async = require('async'),
var websockets = require('./socket.io'); var websockets = require('./socket.io');
if (websockets.server) { if (websockets.server) {
for(var i=0; i<uids.length; ++i) { // Add notification paths to sent notification object as well
websockets.in('uid_' + uids[i]).emit('event:new_notification', notification); async.eachLimit(uids, 50, function(uid, next) {
} User.notifications.generateNotificationPaths([notification], uid, function(err, notifications) {
websockets.in('uid_' + uid).emit('event:new_notification', notifications[0]);
});
});
} }
callback(); callback();

Loading…
Cancel
Save