Skip to content

Commit 4eba108

Browse files
committed
feat: レート制限追加
- Backend APIでは1req/sにしていたが、fronendでは2.2sにした
1 parent 3e10137 commit 4eba108

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

frontend/src/App.svelte

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import Label from "./components/Label.svelte";
55
import Message from "./components/Message.svelte";
66
7+
import { Loader } from "@lucide/svelte";
78
import { type Problem } from "./utils/types";
89
910
let under_diff = $state<string>("0");
@@ -17,13 +18,15 @@
1718
1819
let result = $state<Problem | null>(null);
1920
let errorMessage = $state<string | null>(null);
21+
let loading = $state<boolean>(false);
2022
2123
const sendQuery = async (): Promise<void> => {
2224
if (errors.rangeError || errors.isMinusUnderDiff || errors.isMinusOverDiff) {
2325
return;
2426
}
2527
2628
errorMessage = null;
29+
loading = true;
2730
2831
try {
2932
const API_URL = import.meta.env.VITE_API_URL;
@@ -41,6 +44,10 @@
4144
errorMessage = (err as Error).message;
4245
result = null;
4346
}
47+
48+
setTimeout(() => {
49+
loading = false;
50+
}, 2200);
4451
}
4552
</script>
4653

@@ -63,10 +70,17 @@
6370
<div class="flex items-center gap-2">
6471
<Input type="number" placeholder="最低Diffを入力してください。" isErrors={errors} bind:value={under_diff} />
6572
<Input type="number" placeholder="最高Diffを入力してください。" isErrors={errors} bind:value={over_diff} />
66-
<Button onclick={sendQuery} class="shrink-0">Pick</Button>
73+
<Button onclick={sendQuery} class="shrink-0" disabled={loading}>
74+
{#if loading}
75+
<div class="animate-spin [animation-duration: 2.2s] mr-2">
76+
<Loader size="1rem" />
77+
</div>
78+
{/if}
79+
Pick
80+
</Button>
6781
</div>
6882

69-
{#if result !== null}
83+
{#if !loading && result !== null}
7084
<div class="mt-4">
7185
<Message variant="success">
7286
<div class="flex flex-col">

0 commit comments

Comments
 (0)