From b0c7997128a0710780cc534444918127b29bb77e Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Mon, 2 Oct 2017 19:49:20 +0200 Subject: [PATCH] Notifications: Don't update titles directly, fire an event instead --- src/scripts/tutti/5_1_notifications.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/scripts/tutti/5_1_notifications.js b/src/scripts/tutti/5_1_notifications.js index 63b9c86c..8e006d0d 100644 --- a/src/scripts/tutti/5_1_notifications.js +++ b/src/scripts/tutti/5_1_notifications.js @@ -1,8 +1,5 @@ -// Store the title, to later append notifications count -var page_title = document.title; - -var unread_on_load = 0; +var unread_on_load = false; var unread_new = 0; var first_load = false; @@ -83,13 +80,15 @@ function getNotifications(){ }); // each if (unread_new > 0) { - // Set page title, display notifications and set counter - document.title = '(' + unread_new + ') ' + page_title; + unread_on_load = unread_new; + + // Display notifications count $('#notifications-count').addClass('bloom'); $('#notifications-count').html('' + unread_new + ''); $('#notifications-toggle i').removeClass('pi-notifications-none').addClass('pi-notifications-active'); + + $('body').trigger('pillar:notifications-total-updated', unread_new); } else { - document.title = page_title; $('#notifications-count').removeAttr('class'); $('#notifications-toggle i').removeClass('pi-notifications-active').addClass('pi-notifications-none'); }; @@ -167,6 +166,8 @@ function checkPopNotification(id,username,username_avatar,action,date,context_ob // pop in! popNotification(); + + $('body').trigger('pillar:notifications-total-updated', unread_new); }; }; @@ -311,11 +312,12 @@ $(function() { $(this).addClass('is_read'); }); - document.title = page_title; $('#notifications-count').removeAttr('class'); $('#notifications-toggle i').removeClass('pi-notifications-active').addClass('pi-notifications-none'); - unread_on_load = unread_new; + unread_on_load = 0; + + $('body').trigger('pillar:notifications-total-updated', unread_on_load); }); });