diff --git a/api/src/Framework/Extra.php b/api/src/Framework/Extra.php index f5ccbbaac1..f7b28ec38f 100644 --- a/api/src/Framework/Extra.php +++ b/api/src/Framework/Extra.php @@ -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) { + // 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()).')'); self::$extra['refresh-opener'] = func_get_args(); diff --git a/api/src/Json/Push.php b/api/src/Json/Push.php index 4d50b989aa..cd4eb987a6 100644 --- a/api/src/Json/Push.php +++ b/api/src/Json/Push.php @@ -109,7 +109,7 @@ class Push extends Msg * * @throws Exception\NotOnline */ - protected function checkSetBackend() + protected static function checkSetBackend() { 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; + } } diff --git a/notifications/inc/class.notifications_ajax.inc.php b/notifications/inc/class.notifications_ajax.inc.php index 859455633e..0930a8a125 100644 --- a/notifications/inc/class.notifications_ajax.inc.php +++ b/notifications/inc/class.notifications_ajax.inc.php @@ -88,8 +88,9 @@ class notifications_ajax { private $response; /** + * Do we have a real push server, or only a fallback * - * @var type + * @var bool */ private $isPushServer; @@ -108,12 +109,10 @@ class notifications_ajax { $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)); - Api\Cache::setCache(Api\Cache::INSTANCE, 'notifications','isPushServer', $isPushServer, 86400); - } - $this->isPushServer = $isPushServer; + return !Api\Json\Push::onlyFallback(); + }, [], 900); } /**