add check if only fallback push and skip full refresh (Framework::refresh_opener) for push and supporting apps

This commit is contained in:
Ralf Becker 2020-07-24 09:07:13 +02:00
parent 56dbbf406f
commit b60a9ffff4
3 changed files with 30 additions and 7 deletions

View File

@ -56,6 +56,14 @@ abstract class Extra
*/ */
public static function refresh_opener($msg, $app, $id=null, $type=null, $targetapp=null, $replace=null, $with=null, $msg_type=null) public static function refresh_opener($msg, $app, $id=null, $type=null, $targetapp=null, $replace=null, $with=null, $msg_type=null)
{ {
// if we have real push available and a regular single-entry refresh of a push supporting app, no need to refresh
if (!Json\Push::onlyFallback() &&
!empty($type) && !empty($id) && // $type === null --> full reload
Link::get_registry($app, 'push_data') !== null)
{
self::$extra['message'] = [$msg, $msg_type];
return;
}
//error_log(__METHOD__.'('.array2string(func_get_args()).')'); //error_log(__METHOD__.'('.array2string(func_get_args()).')');
self::$extra['refresh-opener'] = func_get_args(); self::$extra['refresh-opener'] = func_get_args();

View File

@ -109,7 +109,7 @@ class Push extends Msg
* *
* @throws Exception\NotOnline * @throws Exception\NotOnline
*/ */
protected function checkSetBackend() protected static function checkSetBackend()
{ {
if (!isset(self::$backend)) if (!isset(self::$backend))
{ {
@ -142,4 +142,20 @@ class Push extends Msg
} }
} }
} }
/**
* Check if only fallback / no real push available
*
* @return bool true: fallback, false: real push
*/
public static function onlyFallback()
{
try {
self::checkSetBackend();
}
catch (\Exception $e) {
return true;
}
return self::$backend instanceof \notifications_push;
}
} }

View File

@ -88,8 +88,9 @@ class notifications_ajax {
private $response; private $response;
/** /**
* Do we have a real push server, or only a fallback
* *
* @var type * @var bool
*/ */
private $isPushServer; private $isPushServer;
@ -108,12 +109,10 @@ class notifications_ajax {
$this->db = $GLOBALS['egw']->db; $this->db = $GLOBALS['egw']->db;
if (empty(($isPushServer = Api\Cache::getCache(Api\Cache::INSTANCE, 'notifications', 'isPushServer')))) $this->isPushServer = Api\Cache::getInstance('notifications', 'isPushServer', function ()
{ {
$isPushServer = (!((New Api\Json\Push ()) instanceof notifications_push)); return !Api\Json\Push::onlyFallback();
Api\Cache::setCache(Api\Cache::INSTANCE, 'notifications','isPushServer', $isPushServer, 86400); }, [], 900);
}
$this->isPushServer = $isPushServer;
} }
/** /**