mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-05-04 07:23:57 +01:00
[Bug] API / Save data hotfix (#5716)
* Loading data now checks statusCode not error string * Bump version to 1.8.5 --------- Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
This commit is contained in:
parent
ab7d010a17
commit
6460d46a5d
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.8.4",
|
"version": "1.8.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
@ -15,14 +15,17 @@ export class PokerogueSystemSavedataApi extends ApiBase {
|
|||||||
/**
|
/**
|
||||||
* Get a system savedata.
|
* Get a system savedata.
|
||||||
* @param params The {@linkcode GetSystemSavedataRequest} to send
|
* @param params The {@linkcode GetSystemSavedataRequest} to send
|
||||||
* @returns The system savedata as `string` or `null` on error
|
* @returns The system savedata as `string` or either the status code or `null` on error
|
||||||
*/
|
*/
|
||||||
public async get(params: GetSystemSavedataRequest) {
|
public async get(params: GetSystemSavedataRequest): Promise<string | number | null> {
|
||||||
try {
|
try {
|
||||||
const urlSearchParams = this.toUrlSearchParams(params);
|
const urlSearchParams = this.toUrlSearchParams(params);
|
||||||
const response = await this.doGet(`/savedata/system/get?${urlSearchParams}`);
|
const response = await this.doGet(`/savedata/system/get?${urlSearchParams}`);
|
||||||
const rawSavedata = await response.text();
|
const rawSavedata = await response.text();
|
||||||
|
if (!response.ok) {
|
||||||
|
console.warn("Could not get system savedata!", response.status, rawSavedata);
|
||||||
|
return response.status;
|
||||||
|
}
|
||||||
return rawSavedata;
|
return rawSavedata;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn("Could not get system savedata!", err);
|
console.warn("Could not get system savedata!", err);
|
||||||
|
@ -462,8 +462,13 @@ export class GameData {
|
|||||||
|
|
||||||
if (!bypassLogin) {
|
if (!bypassLogin) {
|
||||||
pokerogueApi.savedata.system.get({ clientSessionId }).then(saveDataOrErr => {
|
pokerogueApi.savedata.system.get({ clientSessionId }).then(saveDataOrErr => {
|
||||||
if (!saveDataOrErr || saveDataOrErr.length === 0 || saveDataOrErr[0] !== "{") {
|
if (
|
||||||
if (saveDataOrErr?.startsWith("sql: no rows in result set")) {
|
typeof saveDataOrErr === "number" ||
|
||||||
|
!saveDataOrErr ||
|
||||||
|
saveDataOrErr.length === 0 ||
|
||||||
|
saveDataOrErr[0] !== "{"
|
||||||
|
) {
|
||||||
|
if (saveDataOrErr === 404) {
|
||||||
globalScene.queueMessage(
|
globalScene.queueMessage(
|
||||||
"Save data could not be found. If this is a new account, you can safely ignore this message.",
|
"Save data could not be found. If this is a new account, you can safely ignore this message.",
|
||||||
null,
|
null,
|
||||||
@ -471,7 +476,7 @@ export class GameData {
|
|||||||
);
|
);
|
||||||
return resolve(true);
|
return resolve(true);
|
||||||
}
|
}
|
||||||
if (saveDataOrErr?.includes("Too many connections")) {
|
if (typeof saveDataOrErr === "string" && saveDataOrErr?.includes("Too many connections")) {
|
||||||
globalScene.queueMessage(
|
globalScene.queueMessage(
|
||||||
"Too many people are trying to connect and the server is overloaded. Please try again later.",
|
"Too many people are trying to connect and the server is overloaded. Please try again later.",
|
||||||
null,
|
null,
|
||||||
@ -479,7 +484,6 @@ export class GameData {
|
|||||||
);
|
);
|
||||||
return resolve(false);
|
return resolve(false);
|
||||||
}
|
}
|
||||||
console.error(saveDataOrErr);
|
|
||||||
return resolve(false);
|
return resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1500,7 +1504,7 @@ export class GameData {
|
|||||||
link.remove();
|
link.remove();
|
||||||
};
|
};
|
||||||
if (!bypassLogin && dataType < GameDataType.SETTINGS) {
|
if (!bypassLogin && dataType < GameDataType.SETTINGS) {
|
||||||
let promise: Promise<string | null> = Promise.resolve(null);
|
let promise: Promise<string | null | number> = Promise.resolve(null);
|
||||||
|
|
||||||
if (dataType === GameDataType.SYSTEM) {
|
if (dataType === GameDataType.SYSTEM) {
|
||||||
promise = pokerogueApi.savedata.system.get({ clientSessionId });
|
promise = pokerogueApi.savedata.system.get({ clientSessionId });
|
||||||
@ -1512,7 +1516,7 @@ export class GameData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
promise.then(response => {
|
promise.then(response => {
|
||||||
if (!response?.length || response[0] !== "{") {
|
if (typeof response === "number" || !response?.length || response[0] !== "{") {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user