From 4f016d89ab87da6736aa102e31cbc18dbec9a505 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 27 Oct 2014 08:09:09 +0000 Subject: [PATCH] We notify user every 2 minutes but also is unread messages are different --- js/script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/script.js b/js/script.js index 6366419..dab293c 100644 --- a/js/script.js +++ b/js/script.js @@ -17,6 +17,7 @@ var lastMsgDate = 0; var unreadCountCurrentConv = 0; var unreadCountAllConv = 0; var unreadCountNotifStep = 12; +var lastUnreadCountAllConv = 0; var originalTitle = document.title; $.urlParam = function(name){ @@ -125,10 +126,14 @@ var checkNewMessages = function() { } if (unreadCountAllConv > 0) { - // We notify user every two minutes for all messages - if (unreadCountNotifStep == 0) { + /* + * We notify user every two minutes for all messages + * or if unreadCount changes + */ + if (unreadCountNotifStep == 0 || lastUnreadCountAllConv != unreadCountAllConv) { desktopNotify(unreadCountAllConv + " unread message(s) for all conversations"); unreadCountNotifStep = 12; + lastUnreadCountAllConv = unreadCountAllConv; } } }