mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-28 02:26:10 +00:00
web/DownloadButton: check server info before main request
This commit is contained in:
parent
92008d3012
commit
819c7a4fa0
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue