diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 27c5a60769e..6555408055f 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -984,39 +984,38 @@ export class GameData { if (slotId < 0) { return resolve(false); } - const sessionData: SessionSaveData | null = await this.getSession(slotId); - if (!sessionData) return resolve(false); + if (!sessionData) { + return resolve(false); + } sessionData.runNameText = newName; - const updatedDataStr = JSON.stringify(sessionData); + const encrypted = encrypt(updatedDataStr, bypassLogin); + const secretId = this.secretId; + const trainerId = this.trainerId; - if (bypassLogin) { + if (!bypassLogin) { + pokerogueApi.savedata.session.update({ slot: slotId, trainerId, secretId, clientSessionId },encrypted).then(error => { + if (error) { + console.error("Failed to update session name:", error); + resolve(false); + } else { + localStorage.setItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`, encrypted); + updateUserInfo().then(success => { + if (success !== null && !success) { + return resolve(false); + }}); + resolve(true); + } + }); + } else { localStorage.setItem( `sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`, encrypt(updatedDataStr, bypassLogin), ); resolve(true); - } else { - const encrypted = encrypt(updatedDataStr, bypassLogin); - const secretId = this.secretId; - const trainerId = this.trainerId; - - const error = await pokerogueApi.savedata.session.update( - { slot: slotId, trainerId, secretId, clientSessionId }, - encrypted, - ); - - if (!error) { - localStorage.setItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`, encrypted); - await updateUserInfo(); - resolve(true); - } else { - console.error("Failed to update session name:", error); - resolve(false); - } } }); } diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index 6675d06bf00..0b305446fa9 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -261,7 +261,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { } } else { this.saveSlotSelectCallback = null; - ui.showText("", 0); // Clear any UI text if needed + ui.showText("", 0); originalCallback?.(-1); success = true; } @@ -385,7 +385,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { this.sessionSlotsContainer.add(this.cursorObj); } const cursorPosition = cursor + this.scrollCursor; - const valueHeight = this.sessionSlots[prevSlotIndex ?? 0]?.saveData?.runNameText ? 76 : 76; //nocas + const valueHeight = this.sessionSlots[prevSlotIndex ?? 0]?.saveData?.runNameText ? 76 : 76; const cursorIncrement = cursorPosition * 76; if (this.sessionSlots[cursorPosition] && this.cursorObj) { const hasData = this.sessionSlots[cursorPosition].hasData;