Skip to content

Commit

Permalink
Update only if required
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Nov 14, 2022
1 parent 95cc84a commit 65643bb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lhc_web/lib/core/lhchat/lhchatvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,8 @@ public static function validateStartChat(& $inputForm, & $start_data_fields, & $

public static function validateJSVarsVisitor($visitor, $data) {

$hashData = md5($visitor->online_attr_system . '_' . $visitor->online_attr);

$onlineAttr = $visitor->online_attr_array;
$variableSet = [];

Expand Down Expand Up @@ -990,10 +992,13 @@ public static function validateJSVarsVisitor($visitor, $data) {
$visitor->online_attr = json_encode($onlineAttr);
$visitor->online_attr_array = $onlineAttr;

erLhcoreClassChatEventDispatcher::getInstance()->dispatch('onlineuser.update_js_vars', array('ou' => & $visitor));

$visitor->saveThis(array('update' => array('online_attr', 'online_attr_system')));
$hashChanged = md5($visitor->online_attr_system . '_' . $visitor->online_attr) != $hashData;
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('onlineuser.update_js_vars', array('data_changed' => $hashChanged, 'ou' => & $visitor));

// Update only if data has changed
if ($hashChanged) {
$visitor->saveThis(array('update' => array('online_attr', 'online_attr_system')));
}
}

public static function isValidTimezoneId2($tzid) {
Expand Down

0 comments on commit 65643bb

Please sign in to comment.