From 5de0e7490829eb3d8465cc297d0fe44765c9d724 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 25 Jan 2016 10:24:05 -0500 Subject: [PATCH] Notification paths are now sent back in socket call, so client- side alert now shows more data and is clickable. --- public/src/modules/notifications.js | 31 ++++++++++++++++++++++------- src/notifications.js | 9 ++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index 08b3bea560..faa6ec9700 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -65,13 +65,30 @@ define('notifications', ['sounds', 'translator', 'components'], function(sound, } socket.on('event:new_notification', function(notifData) { - app.alert({ - alert_id: 'new_notif', - title: '[[notifications:new_notification]]', - message: '[[notifications:you_have_unread_notifications]]', - type: 'warning', - timeout: 2000 - }); + // 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', + title: '[[notifications:new_notification]]', + message: '[[notifications:you_have_unread_notifications]]', + type: 'warning', + timeout: 2000 + }; + } + + app.alert(payload); app.refreshTitle(); if (ajaxify.currentPage === 'notifications') { diff --git a/src/notifications.js b/src/notifications.js index 2b6e7e4733..f0e72ceb97 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -195,9 +195,12 @@ var async = require('async'), var websockets = require('./socket.io'); if (websockets.server) { - for(var i=0; i