web/DownloadButton: move server info cache checks to the api lib

This commit is contained in:
wukko
2024-09-22 15:05:40 +06:00
parent 5ba83f3d56
commit dfaef913c4
2 changed files with 25 additions and 25 deletions

View File

@ -6,9 +6,6 @@
import { createDialog } from "$lib/dialogs";
import { downloadFile } from "$lib/download";
import { cachedInfo, getServerInfo } from "$lib/api/server-info";
import { turnstileLoaded } from "$lib/state/turnstile";
import type { DialogInfo } from "$lib/types/dialog";
export let url: string;
@ -66,26 +63,6 @@
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");
return createDialog({
...defaultErrorPopup,
bodyText: $t("error.captcha_ongoing"),
});
}
const response = await API.request(link);
if (!response) {