Skip to content

Commit

Permalink
retry
Browse files Browse the repository at this point in the history
  • Loading branch information
tenmajkl committed Mar 22, 2023
1 parent 3a9ed05 commit bd064af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
16 changes: 9 additions & 7 deletions src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { invoke } from "@tauri-apps/api/tauri";
import Loading from "./lib/Loading.svelte";
import Error from "./lib/Error.svelte";
import Main from "./lib/Main.svelte";
import type { ComponentType } from "svelte";
import { parse } from "/src/profiles"
Expand All @@ -10,21 +9,24 @@
let profiles;
let retry = null;
async function load() {
profiles = await invoke("connect");
component =
profiles
? Main
: Error
;
if (!profiles) {
retry = load;
return;
}
component = Main;
profiles = profiles.map((profile) => parse(profile));
}
setTimeout(() => load(), 1);
</script>

<main class="bg-white w-screen text-primary">
<svelte:component this={component} profiles={profiles} />
<svelte:component this={component} profiles={profiles} retry={retry}/>
</main>

3 changes: 0 additions & 3 deletions src/lib/Error.svelte

This file was deleted.

8 changes: 8 additions & 0 deletions src/lib/Loading.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script>
export let retry;
</script>

<div class="flex justify-center items-center h-screen flex-col">
Hledání lampičky...
<div class="animate-spin">
Expand All @@ -6,4 +10,8 @@
<path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/>
</svg>
</div>
{#if retry}
Hledání lampičky selhalo.
<button on:click={retry} class="bg-primary text-white rounded-md px-4 py-2 mt-4">Zkusit znovu</button>
{/if}
</div>

0 comments on commit bd064af

Please sign in to comment.