Skip to content

Commit

Permalink
Merge pull request #3 from rajesh-rahul/master
Browse files Browse the repository at this point in the history
Fix incorrect button state when loading example replay
  • Loading branch information
rajesh-rahul authored Dec 5, 2024
2 parents ef4c6c3 + 28a2ecf commit 0d53a2c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/components/TopNav.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script lang="ts">
import { Button } from '$lib/components/ui/button';
import { replay } from '$lib/ReplayState.svelte';
let { onFileChange } = $props();
let fileInput: HTMLInputElement | undefined = $state();
let fileLoaded = $state(false);
function resetFile() {
fileInput?.form?.reset();
fileLoaded = false;
onFileChange(null);
}
</script>
Expand All @@ -21,15 +20,14 @@
<input
bind:this={fileInput}
onchange={() => {
fileLoaded = fileInput!.files!.length > 0;
onFileChange(fileInput!.files);
}}
type="file"
hidden
/>
</form>
<Button disabled={fileLoaded} onclick={() => fileInput!.click()}>Open</Button>
<Button disabled={!fileLoaded} onclick={resetFile}>Reset</Button>
<Button disabled={replay.packets.length !== 0} onclick={() => fileInput!.click()}>Open</Button>
<Button disabled={replay.packets.length === 0} onclick={resetFile}>Reset</Button>
</div>
</div>
</div>
Expand Down

0 comments on commit 0d53a2c

Please sign in to comment.