Revert "Fix API endpoints for saving and retrieving system and session data (#2278)"

This reverts commit 6172f3d574.
This commit is contained in:
Matthew Olker 2024-06-15 21:09:32 -04:00
parent 6172f3d574
commit b42c3fac67
2 changed files with 9 additions and 15 deletions

View File

@ -4198,7 +4198,7 @@ export class GameOverPhase extends BattlePhase {
If Offline, execute offlineNewClear(), a localStorage implementation of newClear daily run checks */ If Offline, execute offlineNewClear(), a localStorage implementation of newClear daily run checks */
if (this.victory) { if (this.victory) {
if (!Utils.isLocal) { if (!Utils.isLocal) {
Utils.apiFetch(`savedata/session/newclear?slot=${this.scene.sessionSlotId}`, true) Utils.apiFetch(`savedata/newclear?slot=${this.scene.sessionSlotId}`, true)
.then(response => response.json()) .then(response => response.json())
.then(newClear => doGameOver(newClear)); .then(newClear => doGameOver(newClear));
} else { } else {

View File

@ -313,7 +313,7 @@ export class GameData {
localStorage.setItem(`data_${loggedInUser.username}`, encrypt(systemData, bypassLogin)); localStorage.setItem(`data_${loggedInUser.username}`, encrypt(systemData, bypassLogin));
if (!bypassLogin) { if (!bypassLogin) {
Utils.apiPost(`savedata/system/update?clientSessionId=${clientSessionId}`, systemData, undefined, true) Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}&clientSessionId=${clientSessionId}`, systemData, undefined, true)
.then(response => response.text()) .then(response => response.text())
.then(error => { .then(error => {
this.scene.ui.savingIcon.hide(); this.scene.ui.savingIcon.hide();
@ -347,7 +347,7 @@ export class GameData {
} }
if (!bypassLogin) { if (!bypassLogin) {
Utils.apiFetch(`savedata/system/get?clientSessionId=${clientSessionId}`, true) Utils.apiFetch(`savedata/system?clientSessionId=${clientSessionId}`, true)
.then(response => response.text()) .then(response => response.text())
.then(response => { .then(response => {
if (!response.length || response[0] !== "{") { if (!response.length || response[0] !== "{") {
@ -545,7 +545,7 @@ export class GameData {
return true; return true;
} }
const response = await Utils.apiFetch(`savedata/system/verify?clientSessionId=${clientSessionId}`, true) const response = await Utils.apiPost("savedata/system/verify", JSON.stringify({ clientSessionId: clientSessionId }), undefined, true)
.then(response => response.json()); .then(response => response.json());
if (!response.valid) { if (!response.valid) {
@ -815,7 +815,7 @@ export class GameData {
}; };
if (!bypassLogin && !localStorage.getItem(`sessionData${slotId ? slotId : ""}_${loggedInUser.username}`)) { if (!bypassLogin && !localStorage.getItem(`sessionData${slotId ? slotId : ""}_${loggedInUser.username}`)) {
Utils.apiFetch(`savedata/session/get?slot=${slotId}&clientSessionId=${clientSessionId}`, true) Utils.apiFetch(`savedata/session?slot=${slotId}&clientSessionId=${clientSessionId}`, true)
.then(response => response.text()) .then(response => response.text())
.then(async response => { .then(async response => {
if (!response.length || response[0] !== "{") { if (!response.length || response[0] !== "{") {
@ -963,7 +963,7 @@ export class GameData {
if (success !== null && !success) { if (success !== null && !success) {
return resolve(false); return resolve(false);
} }
Utils.apiFetch(`savedata/session/delete?slot=${slotId}&clientSessionId=${clientSessionId}`, true).then(response => { Utils.apiFetch(`savedata/delete?datatype=${GameDataType.SESSION}&slot=${slotId}&clientSessionId=${clientSessionId}`, true).then(response => {
if (response.ok) { if (response.ok) {
loggedInUser.lastSessionSlot = -1; loggedInUser.lastSessionSlot = -1;
localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ""}_${loggedInUser.username}`); localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ""}_${loggedInUser.username}`);
@ -1027,7 +1027,7 @@ export class GameData {
return resolve([false, false]); return resolve([false, false]);
} }
const sessionData = this.getSessionSaveData(scene); const sessionData = this.getSessionSaveData(scene);
Utils.apiPost(`savedata/session/clear?slot=${slotId}&trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`, JSON.stringify(sessionData), undefined, true).then(response => { Utils.apiPost(`savedata/clear?slot=${slotId}&trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`, JSON.stringify(sessionData), undefined, true).then(response => {
if (response.ok) { if (response.ok) {
loggedInUser.lastSessionSlot = -1; loggedInUser.lastSessionSlot = -1;
localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ""}_${loggedInUser.username}`); localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ""}_${loggedInUser.username}`);
@ -1184,7 +1184,7 @@ export class GameData {
link.remove(); link.remove();
}; };
if (!bypassLogin && dataType < GameDataType.SETTINGS) { if (!bypassLogin && dataType < GameDataType.SETTINGS) {
Utils.apiFetch(`savedata/${dataType === GameDataType.SYSTEM ? "system" : "session"}/get?clientSessionId=${clientSessionId}${dataType === GameDataType.SESSION ? `&slot=${slotId}` : ""}`, true) Utils.apiFetch(`savedata/${dataType === GameDataType.SYSTEM ? "system" : "session"}?clientSessionId=${clientSessionId}${dataType === GameDataType.SESSION ? `&slot=${slotId}` : ""}`, true)
.then(response => response.text()) .then(response => response.text())
.then(response => { .then(response => {
if (!response.length || response[0] !== "{") { if (!response.length || response[0] !== "{") {
@ -1264,13 +1264,7 @@ export class GameData {
if (!success) { if (!success) {
return displayError(`Could not contact the server. Your ${dataName} data could not be imported.`); return displayError(`Could not contact the server. Your ${dataName} data could not be imported.`);
} }
let url: string; Utils.apiPost(`savedata/update?datatype=${dataType}${dataType === GameDataType.SESSION ? `&slot=${slotId}` : ""}&trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`, dataStr, undefined, true)
if (dataType === GameDataType.SESSION) {
url = `savedata/session/update?slot=${slotId}&trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`;
} else {
url = `savedata/system/update?trainerId=${this.trainerId}&secretId=${this.secretId}&clientSessionId=${clientSessionId}`;
}
Utils.apiPost(url, dataStr, undefined, true)
.then(response => response.text()) .then(response => response.text())
.then(error => { .then(error => {
if (error) { if (error) {