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