AntonLV 8 лет назад
Родитель
Сommit
80d3b64602

+ 5 - 4
inc/classes/BxDolLiveUpdates.php

@@ -262,7 +262,8 @@ class BxDolLiveUpdates extends BxDolFactory implements iBxDolSingleton
 			if($bIndexCheck && $iIndex % (int)$aSystem['frequency'] != 0)
 				continue;
 
-			$mixedResponce = $this->_getRequestedDataBySystem($aSystem, (!empty($aCachedData) && isset($aCachedData[$sName]) ? (int)$aCachedData[$sName] : 0));
+			$bCachedDataBySystem = !empty($aCachedData) && isset($aCachedData[$sName]);
+			$mixedResponce = $this->_getRequestedDataBySystem($aSystem, ($bCachedDataBySystem ? (int)$aCachedData[$sName] : 0), !$bCachedDataBySystem);
 			if($mixedResponce === false)
 				continue;
 
@@ -272,13 +273,13 @@ class BxDolLiveUpdates extends BxDolFactory implements iBxDolSingleton
     	return $aResult;
     }
 
-    protected function _getRequestedDataBySystem($aSystem, $iCachedData = 0)
+    protected function _getRequestedDataBySystem($aSystem, $iCachedData = 0, $bInit = true)
     {
 		if(!BxDolService::isSerializedService($aSystem['service_call']))
 			return false;
 
-		$aResponce = BxDolService::callSerialized($aSystem['service_call'], array('count' => (int)$iCachedData));
-		if(empty($aResponce) || !is_array($aResponce) || !isset($aResponce['count'], $aResponce['method']))
+		$aResponce = BxDolService::callSerialized($aSystem['service_call'], array('count' => (int)$iCachedData, 'init' => ($bInit ? 1 : 0)));
+		if(empty($aResponce) || !is_array($aResponce) || !isset($aResponce['count']) || (!$bInit && !isset($aResponce['method'])))
 			return false;
 
 		return $aResponce;

+ 10 - 7
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1478,7 +1478,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     /** 
      * @ref bx_timeline-get_live_updates "get_live_updates"
      */
-    public function serviceGetLiveUpdates($sType, $iOwnerId, $iProfileId, $iCount = 0)
+    public function serviceGetLiveUpdates($sType, $iOwnerId, $iProfileId, $iCount = 0, $iInit = 0)
     {
 		$sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
 
@@ -1493,13 +1493,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 		if($iCountNew == $iCount)
 			return false;
 
+		if((int)$iInit != 0)
+			return array('count' => $iCountNew);
+
     	return array(
-    		'count' => $iCountNew, // required
-    		'method' => $this->_oConfig->getJsObject('view') . '.showLiveUpdate(oData)', // required
-    		'data' => array(
-    			'code' => $this->_oTemplate->getLiveUpdateNotification($sType, $iOwnerId, $iProfileId, $iCount, $iCountNew)
-    		),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
-    	);
+			'count' => $iCountNew, // required (for initialization and visualization)
+			'method' => $this->_oConfig->getJsObject('view') . '.showLiveUpdate(oData)', // required (for visualization)
+			'data' => array(
+				'code' => $this->_oTemplate->getLiveUpdateNotification($sType, $iOwnerId, $iProfileId, $iCount, $iCountNew)
+			),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
+		);
     }
 
     /*

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -93,7 +93,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         //--- Add live update
 		$oModule->actionResumeLiveUpdate($aParams['type'], $aParams['owner_id']);
 
-		$sServiceCall = BxDolService::getSerializedService($this->_oConfig->getName(), 'get_live_updates', array($aParams['type'], $aParams['owner_id'], $oModule->getUserId(), '{count}'));
+		$sServiceCall = BxDolService::getSerializedService($this->_oConfig->getName(), 'get_live_updates', array($aParams['type'], $aParams['owner_id'], $oModule->getUserId(), '{count}', '{init}'));
 		$sLiveUpdatesCode = BxDolLiveUpdates::getInstance()->add($this->_oConfig->getLiveUpdateKey($aParams['type'], $aParams['owner_id']), 1, $sServiceCall);
 		//--- Add live update