From b2fad172e5e96e62481fc9a200f2fbb89c1683e7 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 9 Apr 2015 17:37:24 -0400 Subject: [PATCH] closes #2966 --- public/src/modules/notifications.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index 3f342a1207..c3a9b984de 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -39,12 +39,15 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) { }); notifList.on('click', '[data-nid]', function() { - var nid = this.getAttribute('data-nid'); - - socket.emit('notifications.markRead', nid, function(err) { + var unread = $(this).hasClass('unread'); + if (!unread) { + return; + } + socket.emit('notifications.markRead', $(this).attr('data-nid'), function(err) { if (err) { - app.alertError(err.message); + return app.alertError(err.message); } + increaseNotifCount(-1); }); }); @@ -58,14 +61,13 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) { }); notifList.on('click', '.mark-read', function(e) { - var liEl = $(this.parentNode), - nid = liEl.attr('data-nid'), + var liEl = $(this).parent(), unread = liEl.hasClass('unread'); e.preventDefault(); e.stopPropagation(); - socket.emit('notifications.mark' + (unread ? 'Read' : 'Unread'), nid, function(err) { + socket.emit('notifications.mark' + (unread ? 'Read' : 'Unread'), liEl.attr('data-nid'), function(err) { if (err) { app.alertError(err.message); }