diff --git a/app/assets/javascripts/sidebar.js b/app/assets/javascripts/sidebar.js index ef3cf4423..843eb0845 100644 --- a/app/assets/javascripts/sidebar.js +++ b/app/assets/javascripts/sidebar.js @@ -120,7 +120,7 @@ } function deleteNotification(evt) { - + decrementNotificationCount(); } function initializeChatPanel() { @@ -238,6 +238,16 @@ $('#sidebar-search-results').height('0px'); } + function incrementNotificationCount() { + var count = parseInt($('#sidebar-notification-count').html()); + $('#sidebar-notification-count').html(count + 1); + } + + function decrementNotificationCount() { + var count = parseInt($('#sidebar-notification-count').html()); + $('#sidebar-notification-count').html(count - 1); + } + // TODO // (1) optimize so we're not hitting server on each keyup once > 2 characters are entered // (2) hide any expanded panels once search starts @@ -302,8 +312,7 @@ logger.debug("Added notification " + notifications[payload.notification_id].id + " to array"); logger.debug("Notification size = " + notifications.length); - // set notification count - $('#sidebar-notification-count').html(notifications.length); + incrementNotificationCount(); var template = $("#template-notification-panel").html(); var notificationHtml = context.JK.fillTemplate(template, {