mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-28 18:46:09 +00:00
web/Omnibox: allow input while antibot check is ongoing & fix spinner
This commit is contained in:
parent
8162877a47
commit
c99240339d
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
let isFocused = false;
|
let isFocused = false;
|
||||||
let isDisabled = false;
|
let isDisabled = false;
|
||||||
|
let isBotCheckOngoing = false;
|
||||||
|
let isLoading = false;
|
||||||
|
|
||||||
const validLink = (url: string) => {
|
const validLink = (url: string) => {
|
||||||
try {
|
try {
|
||||||
|
@ -57,18 +59,18 @@
|
||||||
goto("/", { replaceState: true });
|
goto("/", { replaceState: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: figure out why regular processing spinner
|
|
||||||
// doesn't show up after turnstile loads
|
|
||||||
$: if ($cachedInfo?.info?.cobalt?.turnstileSitekey) {
|
$: if ($cachedInfo?.info?.cobalt?.turnstileSitekey) {
|
||||||
if ($turnstileLoaded) {
|
if ($turnstileLoaded) {
|
||||||
isDisabled = false;
|
isBotCheckOngoing = false;
|
||||||
} else {
|
} else {
|
||||||
isDisabled = true;
|
isBotCheckOngoing = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
isBotCheckOngoing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pasteClipboard = () => {
|
const pasteClipboard = () => {
|
||||||
if (isDisabled || $dialogs.length > 0) {
|
if ($dialogs.length > 0 || isDisabled || isLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +79,10 @@
|
||||||
if (matchLink) {
|
if (matchLink) {
|
||||||
$link = matchLink[0];
|
$link = matchLink[0];
|
||||||
|
|
||||||
await tick(); // wait for button to render
|
if (!isBotCheckOngoing) {
|
||||||
downloadButton.download($link);
|
await tick(); // wait for button to render
|
||||||
|
downloadButton.download($link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -88,7 +92,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeydown = (e: KeyboardEvent) => {
|
const handleKeydown = (e: KeyboardEvent) => {
|
||||||
if (!linkInput || $dialogs.length > 0 || isDisabled) {
|
if (!linkInput || $dialogs.length > 0 || isDisabled || isLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +139,8 @@
|
||||||
class:focused={isFocused}
|
class:focused={isFocused}
|
||||||
class:downloadable={validLink($link)}
|
class:downloadable={validLink($link)}
|
||||||
>
|
>
|
||||||
<div id="input-link-icon" class:loading={isDisabled}>
|
<div id="input-link-icon" class:loading={isLoading || isBotCheckOngoing}>
|
||||||
{#if isDisabled}
|
{#if isLoading || isBotCheckOngoing}
|
||||||
<IconLoader2 />
|
<IconLoader2 />
|
||||||
{:else}
|
{:else}
|
||||||
<IconLink />
|
<IconLink />
|
||||||
|
@ -168,6 +172,7 @@
|
||||||
url={$link}
|
url={$link}
|
||||||
bind:this={downloadButton}
|
bind:this={downloadButton}
|
||||||
bind:disabled={isDisabled}
|
bind:disabled={isDisabled}
|
||||||
|
bind:loading={isLoading}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
export let url: string;
|
export let url: string;
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
|
export let loading = false;
|
||||||
|
|
||||||
$: buttonText = ">>";
|
$: buttonText = ">>";
|
||||||
$: buttonAltText = $t("a11y.save.download");
|
$: buttonAltText = $t("a11y.save.download");
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
|
|
||||||
const changeDownloadButton = (state: DownloadButtonState) => {
|
const changeDownloadButton = (state: DownloadButtonState) => {
|
||||||
disabled = state !== "idle";
|
disabled = state !== "idle";
|
||||||
|
loading = state === "think" || state === "check";
|
||||||
|
|
||||||
buttonText = {
|
buttonText = {
|
||||||
idle: ">>",
|
idle: ">>",
|
||||||
|
|
Loading…
Reference in a new issue