forked from extern/egroupware
Check if push server is available otherwise fallback into polling
This commit is contained in:
parent
ea548a90ab
commit
d9ff68a422
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user