diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index af8e0492cdc..d0ec2444afd 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -49,11 +49,12 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['HT $_SESSION['auto_check_events_not_before'] = $nowtime; // auto_check_events_not_before is rounded to previous minute } print 'var nowtime = ' . $nowtime . ';' . "\n"; + print 'var login = \'' . $_SESSION['dol_login'] . '\';' . "\n"; print 'var auto_check_events_not_before = '.$_SESSION['auto_check_events_not_before']. ';'."\n"; print 'var time_js_next_test = Math.max(nowtime, auto_check_events_not_before);'."\n"; - print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined + print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined ?> - + /* Check if permission ok */ if (Notification.permission !== "granted") { Notification.requestPermission() @@ -62,8 +63,10 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['HT /* Launch timer */ // We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. var time_first_execution = (time_auto_update - (nowtime - time_js_next_test)) * 1000; //need milliseconds - console.log("Launch browser notif check: setTimeout to wait time_first_execution="+time_first_execution+" before first check - nowtime = "+nowtime+" auto_check_events_not_before = "+auto_check_events_not_before+" time_js_next_test = "+time_js_next_test+" time_auto_update="+time_auto_update); - setTimeout(first_execution, time_first_execution); //first run auto check + if (login != '') { + console.log("Launch browser notif check: setTimeout to wait time_first_execution="+time_first_execution+" before first check - nowtime = "+nowtime+" auto_check_events_not_before = "+auto_check_events_not_before+" time_js_next_test = "+time_js_next_test+" time_auto_update="+time_auto_update); + setTimeout(first_execution, time_first_execution); + } //first run auto check function first_execution() {