40 lines
978 B
Svelte
40 lines
978 B
Svelte
<script lang="ts">
|
|
import { onMount } from "svelte"
|
|
import { api, type AppStatus } from "./lib/api"
|
|
import Loading from "./lib/Loading.svelte"
|
|
import Bootstrap from "./lib/Bootstrap.svelte"
|
|
import FirstRun from "./lib/FirstRun.svelte"
|
|
import Main from "./lib/Main.svelte"
|
|
|
|
type View = "loading" | "bootstrap" | "first-run" | "main"
|
|
|
|
let view: View = $state("loading")
|
|
|
|
async function refresh() {
|
|
view = "loading"
|
|
let status: AppStatus
|
|
try {
|
|
status = await api.getStatus()
|
|
} catch (e) {
|
|
console.error("get_status failed", e)
|
|
view = "bootstrap"
|
|
return
|
|
}
|
|
if (status.ffmpeg === "missing") view = "bootstrap"
|
|
else if (status.needs_first_run) view = "first-run"
|
|
else view = "main"
|
|
}
|
|
|
|
onMount(refresh)
|
|
</script>
|
|
|
|
{#if view === "loading"}
|
|
<Loading />
|
|
{:else if view === "bootstrap"}
|
|
<Bootstrap onReady={refresh} />
|
|
{:else if view === "first-run"}
|
|
<FirstRun onDone={refresh} />
|
|
{:else}
|
|
<Main />
|
|
{/if}
|