From 819c7a4fa09fd70b0f48caa28f8a5fb4d196345c Mon Sep 17 00:00:00 2001 From: wukko Date: Fri, 20 Sep 2024 18:28:35 +0600 Subject: [PATCH] web/DownloadButton: check server info before main request --- .../components/save/buttons/DownloadButton.svelte | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/src/components/save/buttons/DownloadButton.svelte b/web/src/components/save/buttons/DownloadButton.svelte index 22ae8ccb..6437958e 100644 --- a/web/src/components/save/buttons/DownloadButton.svelte +++ b/web/src/components/save/buttons/DownloadButton.svelte @@ -6,7 +6,7 @@ import { createDialog } from "$lib/dialogs"; import { downloadFile } from "$lib/download"; - import { cachedInfo } from "$lib/api/server-info"; + import { cachedInfo, getServerInfo } from "$lib/api/server-info"; import { turnstileLoaded } from "$lib/state/turnstile"; import type { DialogInfo } from "$lib/types/dialog"; @@ -66,6 +66,17 @@ export const download = async (link: string) => { changeDownloadButton("think"); + await getServerInfo(); + + if (!$cachedInfo) { + changeDownloadButton("error"); + + return createDialog({ + ...defaultErrorPopup, + bodyText: $t("error.api.unreachable"), + }); + } + if ($cachedInfo?.info?.cobalt?.turnstileSitekey && !$turnstileLoaded) { changeDownloadButton("error");