mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 14:02:18 +02:00
Fixed formating and best practices issues:
Rewrote renameSession to be more inline with other API call funtions, removed debugging comments and whitespaces. Signed-off-by: Matheus Alves <matheus.r.noya.alves@tecnico.ulisboa.pt> Co-authored-by: Inês Simões <ines.p.simoes@tecnico.ulisboa.pt>
This commit is contained in:
parent
1e806fa6ff
commit
78d9b7b724
@ -984,39 +984,38 @@ export class GameData {
|
|||||||
if (slotId < 0) {
|
if (slotId < 0) {
|
||||||
return resolve(false);
|
return resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionData: SessionSaveData | null = await this.getSession(slotId);
|
const sessionData: SessionSaveData | null = await this.getSession(slotId);
|
||||||
|
|
||||||
if (!sessionData) return resolve(false);
|
if (!sessionData) {
|
||||||
|
return resolve(false);
|
||||||
|
}
|
||||||
|
|
||||||
sessionData.runNameText = newName;
|
sessionData.runNameText = newName;
|
||||||
|
|
||||||
const updatedDataStr = JSON.stringify(sessionData);
|
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(
|
localStorage.setItem(
|
||||||
`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`,
|
`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`,
|
||||||
encrypt(updatedDataStr, bypassLogin),
|
encrypt(updatedDataStr, bypassLogin),
|
||||||
);
|
);
|
||||||
resolve(true);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.saveSlotSelectCallback = null;
|
this.saveSlotSelectCallback = null;
|
||||||
ui.showText("", 0); // Clear any UI text if needed
|
ui.showText("", 0);
|
||||||
originalCallback?.(-1);
|
originalCallback?.(-1);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
|||||||
this.sessionSlotsContainer.add(this.cursorObj);
|
this.sessionSlotsContainer.add(this.cursorObj);
|
||||||
}
|
}
|
||||||
const cursorPosition = cursor + this.scrollCursor;
|
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;
|
const cursorIncrement = cursorPosition * 76;
|
||||||
if (this.sessionSlots[cursorPosition] && this.cursorObj) {
|
if (this.sessionSlots[cursorPosition] && this.cursorObj) {
|
||||||
const hasData = this.sessionSlots[cursorPosition].hasData;
|
const hasData = this.sessionSlots[cursorPosition].hasData;
|
||||||
|
Loading…
Reference in New Issue
Block a user