From 08ce64ad8bfecd49d1d6e0ff82aeb5aea1355460 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Fri, 11 Sep 2020 18:01:23 +0200 Subject: [PATCH] #19 Last fixes --- src/javascript/enhancements/notifications.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/javascript/enhancements/notifications.js b/src/javascript/enhancements/notifications.js index 7719064..efdbd83 100644 --- a/src/javascript/enhancements/notifications.js +++ b/src/javascript/enhancements/notifications.js @@ -7,7 +7,6 @@ export function init() { }, ".*"); core.runAfterPathnameChange(() => { - console.log('CHANGE') updateNotificationsInTitle(); }, ".*"); } @@ -15,9 +14,7 @@ export function init() { function getNotificationCount() { if (core.isLoggedIn()) { let menuUserText = document.getElementById('materialize-menu-dropdown').innerText.split('\n')[4]; - console.log(menuUserText); let notificationCount = menuUserText.match(/\d+/)?.[0] ?? 0; - console.log(notificationCount); return notificationCount; } else { return 0; @@ -28,6 +25,9 @@ function updateNotificationsInTitle() { let count = getNotificationCount(); if (helper.assigned(count) && count > 0) { - document.title = `(${count}) ${document.title}`; + // document.title is updated after the event is triggered, so we delay our title update by a reasonable time + setTimeout(() => { + document.title = `(${count}) ${document.title}`; + }, 100); } } \ No newline at end of file