feat: use official wasm in worker and cached data info / warning

This commit is contained in:
Samuel 2025-01-21 20:18:39 +01:00
parent a2bc4115a2
commit ff23486fd2
21 changed files with 492 additions and 398 deletions

View file

@ -1,8 +1,13 @@
/* @refresh reload */
import { MetaProvider } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { Router, useNavigate } from "@solidjs/router";
import { render } from "solid-js/web";
import App from "./App";
import { hasCashedData } from "./lib/db-cache";
import { createEffect, Show } from "solid-js";
import { dbLoaded } from "./db";
import { Callout, CalloutContent, CalloutTitle } from "./components/ui/callout";
import { A } from "./components/ui/A";
const root = document.getElementById("root");
@ -18,18 +23,44 @@ if (root) {
<div class="mx-auto max-w-screen-2xl">
<MetaProvider>
<Router
// root={(props) => {
// const navigate = useNavigate();
// const { pathname } = props.location;
root={(props) => {
const navigate = useNavigate();
// createEffect(() => {
// if (!db && pathname !== "/") {
// navigate("/");
// }
// });
createEffect(() => {
if (!dbLoaded() && !hasCashedData() && props.location.pathname !== "/") {
navigate("/");
}
});
// return props.children;
// }}
return (
<>
<Show
when={props.location.pathname !== "/" && !dbLoaded() && hasCashedData()}
fallback={
<Show when={!dbLoaded() && hasCashedData()}>
<Callout variant="default" class="my-4">
There is currently no backup database loaded, but you can watch statistics that have been
cached, meaning only chats you only watched or were preloaded.
<br />
<A href="/overview">Watch cached statistics</A>
</Callout>
</Show>
}
>
<Callout variant="warning" class="my-4">
<CalloutTitle>You are watching cached statistics</CalloutTitle>
<CalloutContent>
Currently there is no backup database loaded. You can only watch statistics that have been
cached, meaning only chats you only watched or were preloaded.
<br />
<A href="/">Load a backup</A>
</CalloutContent>
</Callout>
</Show>
{props.children}
</>
);
}}
>
<App />
</Router>