From 781e25848d2fc5822d43c26a77c2b3d7b1509d39 Mon Sep 17 00:00:00 2001 From: Mumble <171087428+frutescens@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:44:26 -0700 Subject: [PATCH] fixed infinite loop (#3887) Co-authored-by: frutescens --- src/system/game-data.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index e7bc85d9037..d10d6288696 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -635,13 +635,13 @@ export class GameData { async saveRunHistory(scene: BattleScene, runEntry : SessionSaveData, isVictory: boolean): Promise { const runHistoryData = await this.getRunHistoryData(scene); // runHistoryData should always return run history or {} empty object - const timestamps = Object.keys(runHistoryData); - const timestampsNo = timestamps.map(Number); + let timestamps = Object.keys(runHistoryData).map(Number); // Arbitrary limit of 25 entries per user --> Can increase or decrease while (timestamps.length >= RUN_HISTORY_LIMIT ) { - const oldestTimestamp = Math.min.apply(Math, timestampsNo); + const oldestTimestamp = (Math.min.apply(Math, timestamps)).toString(); delete runHistoryData[oldestTimestamp]; + timestamps = Object.keys(runHistoryData).map(Number); } const timestamp = (runEntry.timestamp).toString();