diff --git a/public/javascripts/web-socket-receiver.js b/public/javascripts/web-socket-receiver.js
index c0bfdc578..505afadfb 100644
--- a/public/javascripts/web-socket-receiver.js
+++ b/public/javascripts/web-socket-receiver.js
@@ -8,8 +8,9 @@ var WebSocketReceiver = {
ws.onclose = function() {
Diaspora.widgets.notifications.showNotification({
html: '
' +
- Diaspora.widgets.i18n.t("web_sockets.disconnected") +
- '
'
+ Diaspora.widgets.i18n.t("web_sockets.disconnected") +
+ '',
+ incrementCount: false
});
WSR.debug("socket closed");
diff --git a/public/javascripts/widgets/notifications.js b/public/javascripts/widgets/notifications.js
index 0091720e3..70bf9136b 100644
--- a/public/javascripts/widgets/notifications.js
+++ b/public/javascripts/widgets/notifications.js
@@ -32,14 +32,17 @@
};
};
- Notifications.prototype.showNotification = function(notification) { $(notification.html).prependTo(this.notificationArea)
+ Notifications.prototype.showNotification = function(notification) {
+ $(notification.html).prependTo(this.notificationArea)
.fadeIn(200)
.delay(8000)
.fadeOut(200, function() {
$(this).detach();
});
- this.incrementCount();
+ if(typeof notification.incrementCount === "undefined" || notification.incrementCount) {
+ this.incrementCount();
+ }
};
Notifications.prototype.changeNotificationCount = function(change) {
diff --git a/spec/javascripts/widgets/notifications-spec.js b/spec/javascripts/widgets/notifications-spec.js
index aeedf1d57..c68854205 100644
--- a/spec/javascripts/widgets/notifications-spec.js
+++ b/spec/javascripts/widgets/notifications-spec.js
@@ -50,6 +50,18 @@ describe("Diaspora", function() {
expect($("#notifications div").length).toEqual(1);
});
+
+ it("only increments the notification count if specified to do so", function() {
+ var originalCount = Diaspora.widgets.notifications.count;
+
+ Diaspora.widgets.notifications.showNotification({
+ html: '',
+ incrementCount: false
+ });
+
+ expect(Diaspora.widgets.notifications.count).toEqual(originalCount);
+
+ });
});
});
});