diff --git a/notifications/inc/class.notifications_ajax.inc.php b/notifications/inc/class.notifications_ajax.inc.php index c7b2bf7ec9..859455633e 100644 --- a/notifications/inc/class.notifications_ajax.inc.php +++ b/notifications/inc/class.notifications_ajax.inc.php @@ -87,6 +87,12 @@ class notifications_ajax { */ private $response; + /** + * + * @var type + */ + private $isPushServer; + /** * constructor * @@ -101,6 +107,13 @@ class notifications_ajax { $this->preferences = $prefs->read(); $this->db = $GLOBALS['egw']->db; + + if (empty(($isPushServer = Api\Cache::getCache(Api\Cache::INSTANCE, 'notifications', 'isPushServer')))) + { + $isPushServer = (!((New Api\Json\Push ()) instanceof notifications_push)); + Api\Cache::setCache(Api\Cache::INSTANCE, 'notifications','isPushServer', $isPushServer, 86400); + } + $this->isPushServer = $isPushServer; } /** @@ -126,7 +139,7 @@ class notifications_ajax { { $this->response->jquery('#currentusers', 'text', array((string)$GLOBALS['egw']->session->session_count())); } - + if ($this->isPushServer) $this->response->data(['isPushServer' => true]); $this->get_egwpopup($browserNotify); } diff --git a/notifications/js/notificationajaxpopup.js b/notifications/js/notificationajaxpopup.js index cdf5c07add..c4ede6446b 100644 --- a/notifications/js/notificationajaxpopup.js +++ b/notifications/js/notificationajaxpopup.js @@ -95,8 +95,9 @@ notifications.prototype.run_notifications = function () { var self = this; - this.get_notifications().then(function(){ + this.get_notifications().then(function(_data){ window.clearTimeout(TIMEOUT); + if (_data && _data.isPushServer) return; self.check_browser_notify(); TIMEOUT = self.setTimeout(POLL_INTERVAL); }, @@ -116,8 +117,8 @@ return new Promise (function(_resolve, _reject){ egw.json( "notifications.notifications_ajax.get_notifications",[], - function(){ - _resolve(); + function(_data){ + _resolve(_data); self.check_browser_notify() }).sendRequest(true,'POST', function(_err){ if (_err && _err.statusText) egw.message(_err.statusText);