diff --git a/hwe/sammo/API/Global/GetRecentRecord.php b/hwe/sammo/API/Global/GetRecentRecord.php index ecae8dd8..edf0691d 100644 --- a/hwe/sammo/API/Global/GetRecentRecord.php +++ b/hwe/sammo/API/Global/GetRecentRecord.php @@ -16,13 +16,13 @@ class GetRecentRecord extends \sammo\BaseAPI public function validateArgs(): ?string { $v = new Validator($this->args); - $v->rule('int', 'lastGeneralRecordID') - ->rule('int', 'lastWorldHistoryID'); + $v->rule('integer', 'lastGeneralRecordID') + ->rule('integer', 'lastWorldHistoryID'); if (!$v->validate()) { return $v->errorStr(); } - $this->args['lastGeneralRecordID'] = (int)($this->args['lastGeneralRecordID']??0); - $this->args['lastWorldHistoryID'] = (int)($this->args['lastWorldHistoryID']??0); + $this->args['lastGeneralRecordID'] = (int)($this->args['lastGeneralRecordID'] ?? 0); + $this->args['lastWorldHistoryID'] = (int)($this->args['lastWorldHistoryID'] ?? 0); return null; } @@ -81,38 +81,35 @@ class GetRecentRecord extends \sammo\BaseAPI $globalRecord = $this->getGlobalRecord($lastRecordID); $generalRecord = $this->getGeneralRecord($session->generalID, $lastRecordID); - $flushHistory = true; - $flushGlobalRecord = true; - $flushGeneralRecord = true; + $flushHistory = false; + $flushGlobalRecord = false; + $flushGeneralRecord = false; - if($history){ - if(Util::array_last($history)[0] == $lastHistoryID){ - $flushHistory = false; - array_pop($history); - } - else if(count($history) > static::ROW_LIMIT){ - array_pop($history); - } + if (!$history) { + $flushHistory = false; + } else if (Util::array_last($history)[0] <= $lastHistoryID) { + $flushHistory = false; + array_pop($history); + } else if (count($history) > static::ROW_LIMIT) { + array_pop($history); } - if($globalRecord){ - if(Util::array_last($globalRecord)[0] == $lastRecordID){ - $flushGlobalRecord = false; - array_pop($globalRecord); - } - else if(count($globalRecord) > static::ROW_LIMIT){ - array_pop($globalRecord); - } + if (!$globalRecord) { + $flushGlobalRecord = false; + } else if (Util::array_last($globalRecord)[0] == $lastRecordID) { + $flushGlobalRecord = false; + array_pop($globalRecord); + } else if (count($globalRecord) > static::ROW_LIMIT) { + array_pop($globalRecord); } - if($generalRecord){ - if(Util::array_last($generalRecord)[0] == $lastRecordID){ - $flushGeneralRecord = false; - array_pop($generalRecord); - } - else if(count($generalRecord) > static::ROW_LIMIT){ - array_pop($generalRecord); - } + if (!$generalRecord) { + $flushGeneralRecord = false; + } else if (Util::array_last($generalRecord)[0] == $lastRecordID) { + $flushGeneralRecord = false; + array_pop($generalRecord); + } else if (count($generalRecord) > static::ROW_LIMIT) { + array_pop($generalRecord); } return [ @@ -120,9 +117,9 @@ class GetRecentRecord extends \sammo\BaseAPI 'history' => $history, 'global' => $globalRecord, 'general' => $generalRecord, - 'flushHistory' => $flushHistory?1:0, - 'flushGlobal' => $flushGlobalRecord?1:0, - 'flushGeneral' => $flushGeneralRecord?1:0, + 'flushHistory' => $flushHistory ? 1 : 0, + 'flushGlobal' => $flushGlobalRecord ? 1 : 0, + 'flushGeneral' => $flushGeneralRecord ? 1 : 0, ]; } } diff --git a/hwe/ts/PageFront.vue b/hwe/ts/PageFront.vue index 392d471f..9a17c069 100644 --- a/hwe/ts/PageFront.vue +++ b/hwe/ts/PageFront.vue @@ -21,6 +21,7 @@