mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/DownloadButton: check server info before main request
This commit is contained in:
parent
92008d3012
commit
819c7a4fa0
1 changed files with 12 additions and 1 deletions
|
@ -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