From f0f86ffe7f81735f19ff47cb794e8fb461329449 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 2 Aug 2022 13:29:55 +0200 Subject: [PATCH] fixed confirmed psas showing up again when server goes through maintenance --- frontend/src/ts/elements/psa.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/elements/psa.ts b/frontend/src/ts/elements/psa.ts index 2904b3cf5..05f527e6b 100644 --- a/frontend/src/ts/elements/psa.ts +++ b/frontend/src/ts/elements/psa.ts @@ -17,7 +17,7 @@ function setMemory(id: string): void { window.localStorage.setItem("confirmedPSAs", JSON.stringify(list)); } -async function getLatest(): Promise { +async function getLatest(): Promise { const response = await Ape.psas.get(); if (response.status === 500) { if (window.location.hostname === "localhost") { @@ -38,7 +38,7 @@ async function getLatest(): Promise { ); } - return []; + return null; } else if (response.status === 503) { Notifications.addBanner( "Server is currently under maintenance. Check the status page for more info.", @@ -48,14 +48,17 @@ async function getLatest(): Promise { undefined, true ); - return []; + return null; + } else if (response.status !== 200) { + return null; } return response.data as MonkeyTypes.PSA[]; } export async function show(): Promise { const latest = await getLatest(); - if (latest == null || latest.length == 0) { + if (latest === null) return; + if (latest.length == 0) { clearMemory(); return; }