diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5c2ebda..bb209b5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint code +name: Lint on: # Runs on pushes targeting the default branch diff --git a/src/components/App.jsx b/src/components/App.jsx index 51ec2a1..7a5f5f8 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -1,8 +1,9 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { createBrowserRouter, Navigate, RouterProvider, } from "react-router-dom"; import Sidebar from "./sidebar"; import Chat from "./chat"; import Settings from "./Settings"; +import useIDB from "../utils/idb"; export default function App() { const router = useState(createBrowserRouter([ @@ -26,5 +27,16 @@ export default function App() { }, ]))[0]; - return + const idb = useIDB(); + const [warmup, setWarmUp] = useState(false); + + useEffect(()=>{ + (async function() { + await idb.initDB(); + setWarmUp(true); + })() + // eslint-disable-next-line + }, []) + + return warmup ? : <> } \ No newline at end of file diff --git a/src/utils/idb/index.js b/src/utils/idb/index.js index 040b1d0..4fde475 100644 --- a/src/utils/idb/index.js +++ b/src/utils/idb/index.js @@ -10,9 +10,9 @@ const defaultOptions = { } class IDB { - constructor() { - this.initDB(); - } + // constructor() { + // this.initDB(); + // } /** * Init database so that we can interact with it